- app/vault.py: Fernet-encrypted credential store (app_secret table); key lives only in RECORDGOD_SECRET_KEY (.env, gitignored) — refuses to store anything if the key is unset. - app/settings_routes.py: admin-gated GET/POST /settings/secrets; values encrypted at rest, NEVER returned. Known fields: Woo / Discogs / Cloudflare / DealGod credentials. - site/index.html: recordgod.com landing. site/dash.html: control room (token gate + paste-your-credentials form). main.py loads .env, mounts site at /, store at /store. - Proven: 401 on bad token; DB holds ciphertext (gAAAA…), not plaintext. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
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")
|