SayedZahur786 commited on
Commit
910875a
·
1 Parent(s): 1df309d

fix: robust absolute path fallback for live_dashboard html rendering

Browse files
Files changed (1) hide show
  1. src/server/app.py +13 -2
src/server/app.py CHANGED
@@ -45,11 +45,22 @@ async def runtime_error_handler(request, exc: RuntimeError):
45
  async def root():
46
  """Serve the live dashboard on the root route for HF Spaces."""
47
  import os
48
- base_dir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
 
49
  dashboard_path = os.path.join(base_dir, "live_dashboard.html")
 
 
 
 
 
50
  if os.path.exists(dashboard_path):
51
  return FileResponse(dashboard_path)
52
- return JSONResponse({"status": "healthy", "error": "dashboard not found"})
 
 
 
 
 
53
 
54
 
55
  @app.get("/health")
 
45
  async def root():
46
  """Serve the live dashboard on the root route for HF Spaces."""
47
  import os
48
+ current_file = os.path.abspath(__file__)
49
+ base_dir = os.path.dirname(os.path.dirname(os.path.dirname(current_file)))
50
  dashboard_path = os.path.join(base_dir, "live_dashboard.html")
51
+
52
+ # Fallback to current working directory if not found
53
+ if not os.path.exists(dashboard_path):
54
+ dashboard_path = os.path.join(os.getcwd(), "live_dashboard.html")
55
+
56
  if os.path.exists(dashboard_path):
57
  return FileResponse(dashboard_path)
58
+
59
+ return JSONResponse({
60
+ "status": "healthy",
61
+ "error": "dashboard not found",
62
+ "debug": dashboard_path
63
+ })
64
 
65
 
66
  @app.get("/health")