+30
@@ -0,0 +1,30 @@
|
||||
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
|
||||
|
||||
|
||||
def create_app() -> FastAPI:
|
||||
app = FastAPI(title=settings.app_name, docs_url="/api/docs" if settings.debug else None)
|
||||
install_session_middleware(app)
|
||||
|
||||
base = Path(__file__).resolve().parent
|
||||
templates = Jinja2Templates(directory=str(base / "templates"))
|
||||
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)
|
||||
|
||||
return app
|
||||
|
||||
|
||||
app = create_app()
|
||||
Reference in New Issue
Block a user