Spaces:
Sleeping
Sleeping
File size: 841 Bytes
4c945e0 | 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 30 31 32 33 34 | from fastapi import FastAPI
from contextlib import asynccontextmanager
import gradio as gr
import logging
from backend.routers.api import router
from backend.gradio_app import create_gradio_app
from backend.services.git_sync import git_sync
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
@asynccontextmanager
async def lifespan(app: FastAPI):
# Startup
logger.info("Application starting up...")
git_sync.startup_pull()
yield
# Shutdown
logger.info("Application shutting down...")
app = FastAPI(title="UserSync Backend", lifespan=lifespan)
# Mount API routes
app.include_router(router)
# Mount Gradio Application
gradio_app = create_gradio_app()
app = gr.mount_gradio_app(app, gradio_app, path="/gradio")
@app.get("/")
def root():
return {"message": "Welcome to UserSync API"}
|