Spaces:
Sleeping
Sleeping
fix(runtime): pick writable DATA_DIR via storage module; create dirs on startup; remove hardcoded /data
649d2d5 Download boot.py from HamidOmarov/FastAPI-RAG-API: direct link, hf CLI and curl.
- Browser
- Download file 859 Bytes
-
https://huggingface.co/spaces/HamidOmarov/FastAPI-RAG-API/resolve/1171cbae9bf3d608916df6ab7575cdc9063bddb2/boot.py
- Command line
-
hf download hf://spaces/HamidOmarov/FastAPI-RAG-API@1171cbae9bf3d608916df6ab7575cdc9063bddb2/boot.py
-
curl -L -o boot.py https://huggingface.co/spaces/HamidOmarov/FastAPI-RAG-API/resolve/1171cbae9bf3d608916df6ab7575cdc9063bddb2/boot.py
859 Bytes
| import os, sys, importlib | |
| import uvicorn | |
| candidates = [ | |
| os.getenv("APP_MODULE"), | |
| "app.main:app", | |
| "main:app", | |
| "app.api:app", | |
| "app.server:app", | |
| ] | |
| def try_run(spec: str): | |
| mod, name = spec.split(":") | |
| m = importlib.import_module(mod) | |
| app = getattr(m, name) | |
| port = int(os.getenv("PORT", "7860")) | |
| uvicorn.run(app, host="0.0.0.0", port=port) | |
| if __name__ == "__main__": | |
| last_err = None | |
| for cand in [c for c in candidates if c]: | |
| try: | |
| print(f"[boot] Trying {cand}", flush=True) | |
| try_run(cand) | |
| sys.exit(0) | |
| except Exception as e: | |
| print(f"[boot] Failed {cand}: {e}", flush=True) | |
| last_err = e | |
| print("[boot] No valid APP_MODULE found. Set env APP_MODULE='pkg.module:app'", flush=True) | |
| if last_err: | |
| raise last_err | |
| sys.exit(1) | |