Spaces:
Sleeping
Sleeping
SIN-Deploy-Bot commited on
Commit ·
3f1f71a
1
Parent(s): e3a08fa
fix: reorder routes - mount Gradio after API routes to avoid 404
Browse files- Move app.mount('/') to end of file after all @app decorators
- This ensures /a2a/v1, /health, /.well-known/* are not shadowed by Gradio catch-all
- Standard FastAPI pattern for mixed API+Gradio apps
main.py
CHANGED
|
@@ -236,10 +236,6 @@ def build_gradio_ui() -> gr.Blocks:
|
|
| 236 |
# FastAPI app
|
| 237 |
app = FastAPI(title="A2A Cloud Coder Agent")
|
| 238 |
|
| 239 |
-
# Mount Gradio app at root
|
| 240 |
-
gradio_app = build_gradio_ui()
|
| 241 |
-
app.mount("/", gradio_app.app)
|
| 242 |
-
|
| 243 |
# A2A endpoint
|
| 244 |
app.post("/a2a/v1")(handle_a2a_message)
|
| 245 |
|
|
@@ -257,12 +253,6 @@ async def health() -> JSONResponse:
|
|
| 257 |
}
|
| 258 |
)
|
| 259 |
|
| 260 |
-
# Root endpoint for HF space page
|
| 261 |
-
@app.get("/")
|
| 262 |
-
async def root() -> JSONResponse:
|
| 263 |
-
return JSONResponse({"service": "A2A Cloud Coder", "status": "running"})
|
| 264 |
-
|
| 265 |
-
|
| 266 |
# Agent card endpoint
|
| 267 |
@app.get("/.well-known/agent-card.json")
|
| 268 |
async def agent_card(request: Request) -> JSONResponse:
|
|
@@ -290,6 +280,11 @@ async def oauth_client() -> JSONResponse:
|
|
| 290 |
)
|
| 291 |
|
| 292 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
if __name__ == "__main__":
|
| 294 |
import uvicorn
|
| 295 |
print("🚀 Starting uvicorn on port", int(os.getenv("PORT", 7860)))
|
|
|
|
| 236 |
# FastAPI app
|
| 237 |
app = FastAPI(title="A2A Cloud Coder Agent")
|
| 238 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
# A2A endpoint
|
| 240 |
app.post("/a2a/v1")(handle_a2a_message)
|
| 241 |
|
|
|
|
| 253 |
}
|
| 254 |
)
|
| 255 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
# Agent card endpoint
|
| 257 |
@app.get("/.well-known/agent-card.json")
|
| 258 |
async def agent_card(request: Request) -> JSONResponse:
|
|
|
|
| 280 |
)
|
| 281 |
|
| 282 |
|
| 283 |
+
# Build Gradio UI and mount as catch-all (after all API routes)
|
| 284 |
+
gradio_app = build_gradio_ui()
|
| 285 |
+
app.mount("/", gradio_app.app)
|
| 286 |
+
|
| 287 |
+
|
| 288 |
if __name__ == "__main__":
|
| 289 |
import uvicorn
|
| 290 |
print("🚀 Starting uvicorn on port", int(os.getenv("PORT", 7860)))
|