Spaces:
Runtime error
Runtime error
Commit Β·
f8430db
1
Parent(s): 826cabf
Use demo.app.include_router and demo.launch to fix port collision
Browse files
app.py
CHANGED
|
@@ -2,10 +2,10 @@ import sys
|
|
| 2 |
import subprocess
|
| 3 |
import importlib
|
| 4 |
|
| 5 |
-
# π 1. Self-Healing Auto-Installer
|
| 6 |
while True:
|
| 7 |
try:
|
| 8 |
-
from main import app
|
| 9 |
break
|
| 10 |
except ModuleNotFoundError as e:
|
| 11 |
missing = e.name
|
|
@@ -30,16 +30,17 @@ while True:
|
|
| 30 |
importlib.invalidate_caches()
|
| 31 |
|
| 32 |
import gradio as gr
|
| 33 |
-
import uvicorn
|
| 34 |
|
| 35 |
-
# π 2.
|
| 36 |
with gr.Blocks(title="Tools Backend API") as demo:
|
| 37 |
gr.Markdown("# π CloudAiRambo Tools API Running")
|
| 38 |
gr.Markdown("FastAPI Backend running live with in-memory database and 16 GB RAM.")
|
| 39 |
gr.Markdown("- **Interactive Swagger Docs:** [/docs](/docs)")
|
| 40 |
gr.Markdown("- **Health Check:** [/health](/health)")
|
| 41 |
|
| 42 |
-
|
|
|
|
| 43 |
|
|
|
|
| 44 |
if __name__ == "__main__":
|
| 45 |
-
|
|
|
|
| 2 |
import subprocess
|
| 3 |
import importlib
|
| 4 |
|
| 5 |
+
# π 1. Self-Healing Auto-Installer
|
| 6 |
while True:
|
| 7 |
try:
|
| 8 |
+
from main import app as fastapi_app
|
| 9 |
break
|
| 10 |
except ModuleNotFoundError as e:
|
| 11 |
missing = e.name
|
|
|
|
| 30 |
importlib.invalidate_caches()
|
| 31 |
|
| 32 |
import gradio as gr
|
|
|
|
| 33 |
|
| 34 |
+
# π 2. Create Gradio interface
|
| 35 |
with gr.Blocks(title="Tools Backend API") as demo:
|
| 36 |
gr.Markdown("# π CloudAiRambo Tools API Running")
|
| 37 |
gr.Markdown("FastAPI Backend running live with in-memory database and 16 GB RAM.")
|
| 38 |
gr.Markdown("- **Interactive Swagger Docs:** [/docs](/docs)")
|
| 39 |
gr.Markdown("- **Health Check:** [/health](/health)")
|
| 40 |
|
| 41 |
+
# π 3. Inject all your FastAPI endpoints directly into Gradio
|
| 42 |
+
demo.app.include_router(fastapi_app.router)
|
| 43 |
|
| 44 |
+
# π 4. Launch natively via Gradio (prevents port 7860 collision)
|
| 45 |
if __name__ == "__main__":
|
| 46 |
+
demo.launch()
|