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

fix: serve live_dashboard.html on root route instead of json

Browse files
Files changed (1) hide show
  1. src/server/app.py +9 -10
src/server/app.py CHANGED
@@ -4,7 +4,7 @@ from typing import Any
4
 
5
  from fastapi import FastAPI, HTTPException, Request
6
  from fastapi.middleware.cors import CORSMiddleware
7
- from fastapi.responses import JSONResponse
8
  from pydantic import BaseModel
9
 
10
  from src.models import Action, Observation, State
@@ -42,15 +42,14 @@ async def runtime_error_handler(request, exc: RuntimeError):
42
 
43
 
44
  @app.get("/", include_in_schema=False)
45
- async def root() -> dict[str, Any]:
46
- """Root endpoint for Spaces health probes and browser landing."""
47
- return {
48
- "status": "healthy",
49
- "service": "citywide-dispatch-supervisor",
50
- "health": "/health",
51
- "tasks": "/tasks",
52
- "dashboard_state": "/dashboard/state",
53
- }
54
 
55
 
56
  @app.get("/health")
 
4
 
5
  from fastapi import FastAPI, HTTPException, Request
6
  from fastapi.middleware.cors import CORSMiddleware
7
+ from fastapi.responses import JSONResponse, FileResponse
8
  from pydantic import BaseModel
9
 
10
  from src.models import Action, Observation, State
 
42
 
43
 
44
  @app.get("/", include_in_schema=False)
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")