Spaces:
Sleeping
Sleeping
File size: 761 Bytes
c41f4f3 80de8a7 c41f4f3 fe36e9d c41f4f3 fe36e9d 80de8a7 c41f4f3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import os
import uvicorn
from fastapi import FastAPI
import gradio as gr
from main_service import app as fastapi_app
from commercial_dashboard import demo as gradio_demo
# This is the secret sauce for Hugging Face:
# Mount the FastAPI (Brain) and Gradio (Dashboard) on the same server!
os.environ["UNIFIED_MODE"] = "1"
app = FastAPI()
# Mount existing Brain Service routes
app.mount("/api", fastapi_app)
@app.get("/health")
def health():
return {"status": "ok", "components": ["fastapi", "gradio"]}
# Wrap the Gradio App
app = gr.mount_gradio_app(app, gradio_demo, path="/",
allowed_paths=[os.getcwd()])
if __name__ == "__main__":
# HF looks for an app running on port 7860
uvicorn.run(app, host="0.0.0.0", port=7860)
|