Spaces:
Running on Zero
Running on Zero
Download app.py from manojthapaa/Cognigraph: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/manojthapaa/Cognigraph/resolve/main/app.py
- Command line
-
hf download hf://spaces/manojthapaa/Cognigraph/app.py
-
curl -L -o app.py https://huggingface.co/spaces/manojthapaa/Cognigraph/resolve/main/app.py
1.21 kB
| """ | |
| Hugging Face Spaces entry point. | |
| The Space uses the Gradio SDK (the free tier) but serves the same FastAPI backend | |
| and built React UI as the Docker setup: the Space runs `python app.py`, which | |
| starts the app on port 7860. | |
| """ | |
| import os | |
| import sys | |
| def _report_zerogpu_startup(): | |
| """ | |
| ZeroGPU hardware refuses to start a Space unless it reports at least one | |
| @spaces.GPU function at startup. CogniGraph needs no GPU (the LLMs are remote | |
| APIs), so register a placeholder that is never called and send the report | |
| ourselves: `spaces` normally sends it from gr.Blocks.launch(), which this app | |
| never calls because it serves FastAPI directly. | |
| """ | |
| import spaces | |
| def _zerogpu_placeholder(): | |
| return None | |
| from spaces.zero import startup | |
| startup() | |
| # `spaces` must be imported before anything else that could touch CUDA | |
| if os.getenv("SPACES_ZERO_GPU", "").lower() in ("1", "t", "true"): | |
| _report_zerogpu_startup() | |
| sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "backend")) | |
| import uvicorn | |
| from main import app | |
| if __name__ == "__main__": | |
| uvicorn.run(app, host="0.0.0.0", port=int(os.getenv("PORT", "7860"))) | |