Spaces:
Paused
Paused
Zhen Ye commited on
Commit ·
22ef6b4
1
Parent(s): ff50694
fix: Update static file path for deployment
Browse files
app.py
CHANGED
|
@@ -104,9 +104,11 @@ async def add_no_cache_header(request: Request, call_next):
|
|
| 104 |
return response
|
| 105 |
|
| 106 |
# Optional: serve the LaserPerception frontend from this backend.
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
|
|
|
|
|
|
| 110 |
|
| 111 |
# Valid detection modes
|
| 112 |
VALID_MODES = {"object_detection", "segmentation", "drone_detection"}
|
|
@@ -159,7 +161,8 @@ def _default_queries_for_mode(mode: str) -> list[str]:
|
|
| 159 |
@app.get("/", response_class=HTMLResponse)
|
| 160 |
async def demo_page():
|
| 161 |
"""Redirect to LaserPerception app."""
|
| 162 |
-
|
|
|
|
| 163 |
|
| 164 |
|
| 165 |
@app.post("/detect")
|
|
|
|
| 104 |
return response
|
| 105 |
|
| 106 |
# Optional: serve the LaserPerception frontend from this backend.
|
| 107 |
+
# The frontend files are now located in the 'frontend' directory.
|
| 108 |
+
_FRONTEND_DIR = Path(__file__).with_name("frontend")
|
| 109 |
+
if _FRONTEND_DIR.exists():
|
| 110 |
+
# Mount the entire frontend directory at /laser (legacy path) or /frontend
|
| 111 |
+
app.mount("/laser", StaticFiles(directory=_FRONTEND_DIR, html=True), name="laser")
|
| 112 |
|
| 113 |
# Valid detection modes
|
| 114 |
VALID_MODES = {"object_detection", "segmentation", "drone_detection"}
|
|
|
|
| 161 |
@app.get("/", response_class=HTMLResponse)
|
| 162 |
async def demo_page():
|
| 163 |
"""Redirect to LaserPerception app."""
|
| 164 |
+
# The main entry point is now index.html in the mounted directory
|
| 165 |
+
return RedirectResponse(url="/laser/index.html")
|
| 166 |
|
| 167 |
|
| 168 |
@app.post("/detect")
|