File size: 792 Bytes
bbc89f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
865e3af
bbc89f6
 
 
 
 
 
 
 
 
 
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
28
29
import uvicorn
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from starlette.middleware.sessions import SessionMiddleware
from config import SECRET_KEY
from routes import router, get_user
from gradio_app import login_demo, main_demo
import gradio as gr
from pathlib import Path

app = FastAPI()

login_demo.queue()
main_demo.queue()

static_dir = Path("./static")
app.mount("/static", StaticFiles(directory=static_dir, html=True), name="static")

app.add_middleware(SessionMiddleware, secret_key=SECRET_KEY, max_age=3600)

app.include_router(router)

app = gr.mount_gradio_app(app, login_demo, path="/main")
app = gr.mount_gradio_app(app, main_demo, path="/gradio", auth_dependency=get_user, show_error=True)

if __name__ == "__main__":
    uvicorn.run(app)