37 lines
1011 B
Python
37 lines
1011 B
Python
from pathlib import Path
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.staticfiles import StaticFiles
|
|
from fastapi.templating import Jinja2Templates
|
|
|
|
from app.config import settings
|
|
from app.deps import install_session_middleware
|
|
from app.routers import admin, auth, public, xui
|
|
|
|
|
|
def create_app() -> FastAPI:
|
|
app = FastAPI(
|
|
title=settings.app_name,
|
|
version=settings.app_version,
|
|
docs_url="/api/docs" if settings.debug else None,
|
|
)
|
|
install_session_middleware(app)
|
|
|
|
base = Path(__file__).resolve().parent
|
|
templates = Jinja2Templates(directory=str(base / "templates"))
|
|
templates.env.globals["app_version"] = settings.app_version
|
|
app.state.templates = templates
|
|
app.state.settings = settings
|
|
|
|
app.mount("/static", StaticFiles(directory=str(base / "static")), name="static")
|
|
|
|
app.include_router(public.router)
|
|
app.include_router(auth.router)
|
|
app.include_router(admin.router)
|
|
app.include_router(xui.router)
|
|
|
|
return app
|
|
|
|
|
|
app = create_app()
|