28 lines
820 B
Python
28 lines
820 B
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.staticfiles import StaticFiles
|
|
|
|
from app.config import Settings
|
|
from app.routes.api import router as api_router
|
|
from app.routes.ui import router as ui_router
|
|
from app.services.store import JSONStore
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent
|
|
|
|
|
|
def create_app(state_dir: Path | str | None = None) -> FastAPI:
|
|
settings = Settings()
|
|
app = FastAPI(title=settings.app_name)
|
|
resolved_state_dir = Path(state_dir) if state_dir is not None else settings.default_state_dir
|
|
app.state.store = JSONStore(resolved_state_dir)
|
|
app.mount('/static', StaticFiles(directory=BASE_DIR / 'static'), name='static')
|
|
app.include_router(ui_router)
|
|
app.include_router(api_router)
|
|
return app
|
|
|
|
|
|
app = create_app()
|