spb/forma-ka Public
Python 65.1%
TypeScript 17.9%
CSS 16.4%
HTML 0.5%
1#!/usr/bin/env python32# -----------------------------------------------------------------------------3# Forma-Ka — Agrégateur de formations (province de Québec)4# Auteur : Simon-Pierre Boucher — contact@spboucher.ai5# run.py : point d'entrée — `sync`, `watch`, `serve`6# -----------------------------------------------------------------------------7"""Utilisation :8 python run.py sync [source ...] # synchronise les formations9 python run.py watch [minutes] # synchronise en boucle (défaut 360 min)10 python run.py serve [port] # démarre l'API + le frontend (défaut 8080)11"""12from __future__ import annotations1314import os15import sys16from pathlib import Path1718# Charger .env (FIRECRAWL_API_KEY, SCRAPFLY_API_KEY…) sans dépendance externe19_env = Path(__file__).parent / ".env"20if _env.exists():21 for line in _env.read_text().splitlines():22 line = line.strip()23 if line and not line.startswith("#") and "=" in line:24 k, _, v = line.partition("=")25 os.environ.setdefault(k.strip(), v.strip())262728def main() -> None:29 cmd = sys.argv[1] if len(sys.argv) > 1 else "serve"30 if cmd == "sync":31 from formaka import ingest32 ingest.run(sys.argv[2:] or None)33 elif cmd == "watch":34 from formaka import ingest35 minutes = int(sys.argv[2]) if len(sys.argv) > 2 else 36036 ingest.watch(minutes * 60)37 elif cmd == "serve":38 import uvicorn39 port = int(sys.argv[2]) if len(sys.argv) > 2 else 808040 uvicorn.run("formaka.web:app", host="0.0.0.0", port=port)41 else:42 print(__doc__)43 sys.exit(1)444546if __name__ == "__main__":47 main()48