SPB Git forge

spb/qc-election

Public
20commits 1branches 0releases
4.9 MBsize
maindefault branch
20 days agolast push
Python 66.6% HTML 24.8% CSS 4.9% JavaScript 3.6%

config: charger backend/.env dans os.environ à l'import (PM2 ne transmet pas d'env_file — ADMIN_TOKEN/FIRECRAWL_API_KEY n'étaient jamais lus depuis le fichier)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Simon-Pierre Boucher committed 25 days ago (Aug 30, 2026) parent 4ff14e4

1 changed file +17 −0

modified backend/app/config.py +17 −0
@@ -16,6 +16,23 @@ DATA_DIR = BASE_DIR / "data"
16 16 FRONTEND_DIR = BASE_DIR.parent / "frontend"
17 17
18 18
19 +def _load_env_file(path: Path) -> None:
20 + """Charge backend/.env dans os.environ (sans écraser l'existant) — PM2 ne
21 + transmet pas de fichier d'environnement, et les défauts `os.environ.get(...)`
22 + ci-dessous (ADMIN_TOKEN, FIRECRAWL_API_KEY…) doivent le voir."""
23 + if not path.exists():
24 + return
25 + for line in path.read_text().splitlines():
26 + line = line.strip()
27 + if not line or line.startswith("#") or "=" not in line:
28 + continue
29 + k, _, v = line.partition("=")
30 + os.environ.setdefault(k.strip(), v.strip().strip('"').strip("'"))
31 +
32 +
33 +_load_env_file(BASE_DIR / ".env")
34 +
35 +
19 36 class Settings(BaseSettings):
20 37 # --- Général ---
21 38 app_name: str = "QC Élection Forecast"
22 39