visproj commited on
Commit
9c269a5
Β·
verified Β·
1 Parent(s): 35b6f7a

redirect to ui

Browse files
Files changed (1) hide show
  1. app.py +10 -5
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
- # Create Gradio ASGI app
452
- gradio_app = gr.routes.App.create_app(app)
 
 
453
 
454
- # Mount Gradio at root path for main UI
455
- fastapi_app.mount("/", gradio_app)
 
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