Spaces:
Sleeping
Sleeping
Run demo.launch() only to avoid port conflict
Browse files- gradio_app.py +7 -5
gradio_app.py
CHANGED
|
@@ -113,7 +113,7 @@ app.add_middleware(
|
|
| 113 |
allow_headers=["*"],
|
| 114 |
)
|
| 115 |
|
| 116 |
-
#
|
| 117 |
pre_insertion_route_count = len(app.router.routes)
|
| 118 |
|
| 119 |
# Include custom API routes directly on Gradio FastAPI app
|
|
@@ -124,10 +124,12 @@ def health_check(request: Request):
|
|
| 124 |
|
| 125 |
app.include_router(api_router, prefix="/api/v1")
|
| 126 |
|
| 127 |
-
#
|
| 128 |
-
# This prevents Gradio's catch-all wildcard routes from intercepting API endpoints
|
| 129 |
new_route_count = len(app.router.routes) - pre_insertion_route_count
|
| 130 |
if new_route_count > 0:
|
| 131 |
-
# Extract the new routes, prepend them to the original list of routes
|
| 132 |
app.router.routes = app.router.routes[-new_route_count:] + app.router.routes[:-new_route_count]
|
| 133 |
-
logger.info(f"Successfully prepended {new_route_count} API routes to bypass Gradio wildcard
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
allow_headers=["*"],
|
| 114 |
)
|
| 115 |
|
| 116 |
+
# Prepend routes to bypass Gradio wildcard catch-all route matching
|
| 117 |
pre_insertion_route_count = len(app.router.routes)
|
| 118 |
|
| 119 |
# Include custom API routes directly on Gradio FastAPI app
|
|
|
|
| 124 |
|
| 125 |
app.include_router(api_router, prefix="/api/v1")
|
| 126 |
|
| 127 |
+
# Prepend the newly added routes
|
|
|
|
| 128 |
new_route_count = len(app.router.routes) - pre_insertion_route_count
|
| 129 |
if new_route_count > 0:
|
|
|
|
| 130 |
app.router.routes = app.router.routes[-new_route_count:] + app.router.routes[:-new_route_count]
|
| 131 |
+
logger.info(f"Successfully prepended {new_route_count} API routes to bypass Gradio wildcard.")
|
| 132 |
+
|
| 133 |
+
# Launch the Gradio app blocks directly (Gradio reads port 7860 from env and starts the server)
|
| 134 |
+
# This blocks execution and keeps the container process alive on port 7860
|
| 135 |
+
demo.launch()
|