Spaces:
Paused
Paused
Hemang Thakur
commited on
Commit
·
b2da7d4
1
Parent(s):
d576baf
moved catch-all route to last
Browse files
main.py
CHANGED
@@ -543,17 +543,6 @@ app.add_middleware(
|
|
543 |
# Serve the React app (the production build) at the root URL.
|
544 |
app.mount("/static", StaticFiles(directory="frontend/build/static", html=True), name="static")
|
545 |
|
546 |
-
# Catch-all route for frontend paths.
|
547 |
-
@app.get("/{full_path:path}")
|
548 |
-
async def serve_frontend(full_path: str, request: Request):
|
549 |
-
if full_path.startswith("action") or full_path in ["settings", "stop"]:
|
550 |
-
raise HTTPException(status_code=404, detail="Not Found")
|
551 |
-
|
552 |
-
index_path = os.path.join("frontend", "build", "index.html")
|
553 |
-
if not os.path.exists(index_path):
|
554 |
-
raise HTTPException(status_code=500, detail="Frontend build not found")
|
555 |
-
return FileResponse(index_path)
|
556 |
-
|
557 |
# Define the routes for the FastAPI app
|
558 |
|
559 |
# Define the route for sources action to display search results
|
@@ -760,4 +749,12 @@ def stop():
|
|
760 |
state["process_task"].cancel()
|
761 |
del state["process_task"]
|
762 |
|
763 |
-
return {"message": "Stopped task manually"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
543 |
# Serve the React app (the production build) at the root URL.
|
544 |
app.mount("/static", StaticFiles(directory="frontend/build/static", html=True), name="static")
|
545 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
546 |
# Define the routes for the FastAPI app
|
547 |
|
548 |
# Define the route for sources action to display search results
|
|
|
749 |
state["process_task"].cancel()
|
750 |
del state["process_task"]
|
751 |
|
752 |
+
return {"message": "Stopped task manually"}
|
753 |
+
|
754 |
+
# Catch-all route for frontend paths.
|
755 |
+
@app.get("/{full_path:path}")
|
756 |
+
async def serve_frontend(full_path: str, request: Request):
|
757 |
+
index_path = os.path.join("frontend", "build", "index.html")
|
758 |
+
if not os.path.exists(index_path):
|
759 |
+
raise HTTPException(status_code=500, detail="Frontend build not found")
|
760 |
+
return FileResponse(index_path)
|