bapi143 commited on
Commit
b4b1776
·
1 Parent(s): 36c06b8

Pass backend routes and docs_url directly into demo.launch app_kwargs

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -60,14 +60,14 @@ with gr.Blocks(title="🌾 CropAI Agronomic Cloud") as demo:
60
  * **Drone VRA:** Autonomous Spot-Spraying Lawnmower Grid Generator
61
  """)
62
 
63
- # Attach all FastAPI backend routes onto Gradio's internal FastAPI app
64
- demo.app.include_router(backend_app.router)
65
-
66
- # Move Gradio's catch-all SPA routes to the very end so that REST API endpoints
67
- # (/api/v1/..., /health, /docs) take full precedence without interference.
68
- non_catchall = [r for r in demo.app.router.routes if '{path:path}' not in getattr(r, 'path', '')]
69
- catchall = [r for r in demo.app.router.routes if '{path:path}' in getattr(r, 'path', '')]
70
- demo.app.router.routes = non_catchall + catchall
71
-
72
  if __name__ == "__main__":
73
- demo.launch(ssr_mode=False)
 
 
 
 
 
 
 
 
 
 
60
  * **Drone VRA:** Autonomous Spot-Spraying Lawnmower Grid Generator
61
  """)
62
 
 
 
 
 
 
 
 
 
 
63
  if __name__ == "__main__":
64
+ demo.launch(
65
+ ssr_mode=False,
66
+ app_kwargs={
67
+ "routes": list(backend_app.routes),
68
+ "docs_url": "/docs",
69
+ "redoc_url": "/redoc",
70
+ "title": "CropAI Agricultural Cloud API",
71
+ "version": "1.2.0"
72
+ }
73
+ )