- requirements-dev.txt with pytest and httpx
- tests/conftest.py: client and tmp_data_dir fixtures
- tests/test_health.py: GET /health returns 200 with {"status": "ok"}
- tests/test_static.py: no CDN URLs in templates, dashboard returns 200
- Fix imptune/api/pages.py: use request= kwarg in TemplateResponse (Starlette compat)
- Fix imptune/main.py: replace deprecated on_event with asynccontextmanager lifespan
28 lines
729 B
Python
28 lines
729 B
Python
import os
|
|
from contextlib import asynccontextmanager
|
|
from pathlib import Path
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.staticfiles import StaticFiles
|
|
|
|
from imptune.api import health, pages
|
|
from imptune.config import DATA_DIR, DRIVERS_DIR
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
os.makedirs(DATA_DIR, exist_ok=True)
|
|
os.makedirs(DRIVERS_DIR, exist_ok=True)
|
|
yield
|
|
|
|
|
|
app = FastAPI(title="ImpTune", lifespan=lifespan)
|
|
|
|
# Serve baked-in static assets (pico.min.css, htmx.min.js, alpine.min.js)
|
|
_static_dir = Path(__file__).parent / "static"
|
|
app.mount("/static", StaticFiles(directory=str(_static_dir)), name="static")
|
|
|
|
# Register routers
|
|
app.include_router(health.router)
|
|
app.include_router(pages.router)
|