File size: 863 Bytes
e8e33af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9b12844
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
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)
        
@asynccontextmanager
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="/")