spb/auto-ka Public
Python 82.3%
TypeScript 12%
CSS 5.4%
1#!/usr/bin/env python32# -----------------------------------------------------------------------------3# Auto-Ka — Agrégateur de voitures usagées à vendre (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 annonces9 python run.py watch [minutes] # synchronise en boucle (défaut 120 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, etc.) 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 autoka import ingest32 ingest.run(sys.argv[2:] or None)33 elif cmd == "watch":34 from autoka import ingest35 minutes = int(sys.argv[2]) if len(sys.argv) > 2 else 12036 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("autoka.web:app", host="0.0.0.0", port=port)41 else:42 print(__doc__)43 sys.exit(1)444546if __name__ == "__main__":47 main()48