Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -88,19 +88,21 @@ def debug_env():
|
|
| 88 |
# ✅ Self-test route: checks if all main routes are reachable
|
| 89 |
@app.route("/self-test")
|
| 90 |
def self_test():
|
| 91 |
-
base_url = os.environ.get("PUBLIC_URL", "https://roshcheeku-student-admin.hf.space")
|
| 92 |
-
routes = ["/", "/test-db", "/debug-env", "/auth", "/courses", "/feedback", "/profile", "/admin"]
|
| 93 |
results = {}
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
return jsonify(results)
|
| 105 |
|
| 106 |
logger.info(">>> Finished loading app.py (Gunicorn should now serve the app)")
|
|
|
|
| 88 |
# ✅ Self-test route: checks if all main routes are reachable
|
| 89 |
@app.route("/self-test")
|
| 90 |
def self_test():
|
|
|
|
|
|
|
| 91 |
results = {}
|
| 92 |
+
routes = ["/", "/test-db", "/debug-env", "/auth", "/courses", "/feedback", "/profile", "/admin"]
|
| 93 |
+
|
| 94 |
+
with app.test_client() as client:
|
| 95 |
+
for r in routes:
|
| 96 |
+
try:
|
| 97 |
+
res = client.get(r)
|
| 98 |
+
results[r] = {
|
| 99 |
+
"status_code": res.status_code,
|
| 100 |
+
"ok": res.status_code == 200,
|
| 101 |
+
"response": res.json if res.is_json else res.data.decode("utf-8")
|
| 102 |
+
}
|
| 103 |
+
except Exception as e:
|
| 104 |
+
results[r] = {"error": str(e)}
|
| 105 |
+
|
| 106 |
return jsonify(results)
|
| 107 |
|
| 108 |
logger.info(">>> Finished loading app.py (Gunicorn should now serve the app)")
|