Spaces:
Runtime error
Runtime error
Download scripts/gen_openapi.py from openscopelabs/cctv-object-detection: direct link, hf CLI and curl.
- Browser
- Download file 789 Bytes
-
https://huggingface.co/spaces/openscopelabs/cctv-object-detection/resolve/main/scripts/gen_openapi.py
- Command line
-
hf download hf://spaces/openscopelabs/cctv-object-detection/scripts/gen_openapi.py
-
curl -L -o gen_openapi.py https://huggingface.co/spaces/openscopelabs/cctv-object-detection/resolve/main/scripts/gen_openapi.py
789 Bytes
| """Dump the FastAPI OpenAPI 3.1 spec to docs/apispec.json. | |
| Run from the project root: | |
| .venv/bin/python -m scripts.gen_openapi | |
| Importing app.main only constructs the app; lifespan startup | |
| (YOLO load, DB connect) does NOT run, so this is safe to invoke | |
| without network or GPU access.""" | |
| from __future__ import annotations | |
| import json | |
| import sys | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| OUT = ROOT / "docs" / "apispec.json" | |
| # Importing app instantiates FastAPI() — that's all we need. | |
| from app.main import app # noqa: E402 | |
| spec = app.openapi() | |
| OUT.parent.mkdir(parents=True, exist_ok=True) | |
| OUT.write_text(json.dumps(spec, indent=2, ensure_ascii=False) + "\n") | |
| print(f"wrote {OUT.relative_to(ROOT)} ({OUT.stat().st_size:,} bytes)", file=sys.stderr) | |