rasAli02 commited on
Commit
de195a4
·
1 Parent(s): 8fe24d7

Add SPA fallback for React Router

Browse files
Files changed (1) hide show
  1. app.py +0 -13
app.py CHANGED
@@ -510,19 +510,6 @@ with gr.Blocks(title="ForgeSight Admin") as demo:
510
  # Mount Gradio
511
  app = gr.mount_gradio_app(app, demo, path="/gradio")
512
 
513
- # If build folder exists, serve it
514
- if os.path.exists("build"):
515
- app.mount("/static", StaticFiles(directory="build/static"), name="static")
516
-
517
- @app.get("/{rest_of_path:path}")
518
- async def serve_react(rest_of_path: str):
519
- # Allow Gradio and API paths through
520
- if rest_of_path.startswith(("api", "gradio")):
521
- return JSONResponse({"detail": "Not Found"}, status_code=404)
522
-
523
- file_path = os.path.join("build", rest_of_path)
524
- if os.path.isfile(file_path):
525
- return FileResponse(file_path)
526
  return FileResponse("build/index.html")
527
 
528
  if __name__ == "__main__":
 
510
  # Mount Gradio
511
  app = gr.mount_gradio_app(app, demo, path="/gradio")
512
 
 
 
 
 
 
 
 
 
 
 
 
 
 
513
  return FileResponse("build/index.html")
514
 
515
  if __name__ == "__main__":