CoolFace
Apppublic

nappingCommodore/bihar-procurement-analysis

sourceHugging Facemitupdated 2mo agoView on Hugging Face
0likes
start.py23 linesDownload Raw Back to root
1#!/usr/bin/env python2"""Container entrypoint — cross-platform (no shell line-ending pitfalls).3 4* Binds $PORT if the platform injects one (Render / Railway), else 7860 (HF / Fly).5* Downloads the DB from $DB_URL at boot if it isn't baked into the image6  (e.g. the copy already hosted on your Hugging Face Space).7"""8 9import os10import sys11import urllib.request12 13db = os.environ.get("BIHAR_DB", "")14if db and not os.path.exists(db) and os.environ.get("DB_URL"):15    print(f"Database not found at {db} — downloading from $DB_URL ...", flush=True)16    os.makedirs(os.path.dirname(db) or ".", exist_ok=True)17    urllib.request.urlretrieve(os.environ["DB_URL"], db)18    print("Download complete.", flush=True)19 20port = os.environ.get("PORT") or "7860"21os.execvp(sys.executable, [sys.executable, "-m", "uvicorn", "web.app:app",22                           "--host", "0.0.0.0", "--port", port])23