Spaces:
Sleeping
Sleeping
| from contextlib import asynccontextmanager | |
| from fastapi import FastAPI | |
| import gradio as gr # <--- 1. Import Gradio | |
| from .storage.database import engine | |
| from .storage.models import Base | |
| from .routers.parse_router import router as parse_router | |
| from .ui.gradio_ui import gradio_app # <--- 2. Import your UI object | |
| async def create_all_tables(): | |
| async with engine.begin() as conn: | |
| await conn.run_sync(Base.metadata.create_all) | |
| async def lifespan(app: FastAPI): | |
| await create_all_tables() | |
| yield | |
| app = FastAPI(lifespan=lifespan) | |
| # Include your API router | |
| app.include_router(parse_router, prefix="/parse", tags=["parse-image"]) | |
| # 3. Mount Gradio UI | |
| # Now your supervisor can visit http://localhost:8000/ui | |
| #app = gr.mount_gradio_app(app, gradio_app, path="/ui") | |
| app = gr.mount_gradio_app(app, gradio_app, path="/") |