import os import pathlib # Load .env FIRST so auth/db/vault see their keys at import time. _ENV = pathlib.Path(__file__).resolve().parent.parent / ".env" if _ENV.exists(): for _ln in _ENV.read_text().splitlines(): _ln = _ln.strip() if _ln and not _ln.startswith("#") and "=" in _ln: _k, _v = _ln.split("=", 1) os.environ.setdefault(_k.strip(), _v.strip()) from fastapi import FastAPI # noqa: E402 from fastapi.staticfiles import StaticFiles # noqa: E402 from . import __version__ # noqa: E402 from .wowplatter_v1 import router as wowplatter_v1_router # noqa: E402 from .virtual import router as virtual_router # noqa: E402 from .settings_routes import router as settings_router # noqa: E402 app = FastAPI(title="RECORDGOD", version=__version__) app.include_router(wowplatter_v1_router) app.include_router(virtual_router) app.include_router(settings_router) @app.get("/healthz") async def healthz(): return {"ok": True, "service": "recordgod", "version": __version__} _ROOT = pathlib.Path(__file__).resolve().parent.parent # Mounts come last so the API routes + /healthz match first; "/" serves the landing/dash site. if (_ROOT / "webstore").is_dir(): app.mount("/store", StaticFiles(directory=str(_ROOT / "webstore"), html=True), name="store") if (_ROOT / "site").is_dir(): app.mount("/", StaticFiles(directory=str(_ROOT / "site"), html=True), name="site")