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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -24
app.py CHANGED
@@ -442,27 +442,9 @@ if __name__ == "__main__":
442
  print("Please set either OPENAI_API_KEY or ANTHROPIC_API_KEY in your .env file")
443
  print(f"Example: echo 'OPENAI_API_KEY=your_key_here' > .env")
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
-
467
- # Run with uvicorn
468
- uvicorn.run(fastapi_app, host="0.0.0.0", port=7860)
 
442
  print("Please set either OPENAI_API_KEY or ANTHROPIC_API_KEY in your .env file")
443
  print(f"Example: echo 'OPENAI_API_KEY=your_key_here' > .env")
444
 
445
+ # Launch Gradio UI
446
+ app.launch(
447
+ server_name="0.0.0.0",
448
+ server_port=7860,
449
+ share=False
450
+ )