roshcheeku commited on
Commit
e7befe4
·
verified ·
1 Parent(s): bdd98b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -12
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
- for r in routes:
95
- try:
96
- res = requests.get(base_url + r, timeout=5)
97
- results[r] = {
98
- "status_code": res.status_code,
99
- "ok": res.ok,
100
- "response": res.json() if res.headers.get("Content-Type", "").startswith("application/json") else res.text
101
- }
102
- except Exception as e:
103
- results[r] = {"error": str(e)}
 
 
 
 
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)")