redirect to ui
Browse files
app.py
CHANGED
|
@@ -444,18 +444,23 @@ if __name__ == "__main__":
|
|
| 444 |
|
| 445 |
# Combine FastAPI (MCP endpoints) + Gradio (UI) in one Space
|
| 446 |
import uvicorn
|
|
|
|
| 447 |
|
| 448 |
# Get the MCP FastAPI app with all MCP endpoints
|
| 449 |
fastapi_app = mcp_http_host.get_app()
|
| 450 |
|
| 451 |
-
#
|
| 452 |
-
|
|
|
|
|
|
|
| 453 |
|
| 454 |
-
#
|
| 455 |
-
|
|
|
|
| 456 |
|
| 457 |
print("β
MCP Generator starting...")
|
| 458 |
-
print("π Gradio UI: http://0.0.0.0:7860/")
|
|
|
|
| 459 |
print("π§ MCP List: http://0.0.0.0:7860/mcps")
|
| 460 |
print("π Generated MCPs: /{mcp_id}/mcp")
|
| 461 |
|
|
|
|
| 444 |
|
| 445 |
# Combine FastAPI (MCP endpoints) + Gradio (UI) in one Space
|
| 446 |
import uvicorn
|
| 447 |
+
from fastapi.responses import RedirectResponse
|
| 448 |
|
| 449 |
# Get the MCP FastAPI app with all MCP endpoints
|
| 450 |
fastapi_app = mcp_http_host.get_app()
|
| 451 |
|
| 452 |
+
# Add redirect from root to Gradio UI
|
| 453 |
+
@fastapi_app.get("/")
|
| 454 |
+
async def root():
|
| 455 |
+
return RedirectResponse(url="/ui")
|
| 456 |
|
| 457 |
+
# Create Gradio ASGI app and mount at /ui
|
| 458 |
+
gradio_app = gr.routes.App.create_app(app)
|
| 459 |
+
fastapi_app.mount("/ui", gradio_app)
|
| 460 |
|
| 461 |
print("β
MCP Generator starting...")
|
| 462 |
+
print("π Gradio UI: http://0.0.0.0:7860/ui")
|
| 463 |
+
print("π Root (/) redirects to /ui")
|
| 464 |
print("π§ MCP List: http://0.0.0.0:7860/mcps")
|
| 465 |
print("π Generated MCPs: /{mcp_id}/mcp")
|
| 466 |
|