Systematic-tool-review / run_space.py
Sadum1's picture
Upload folder using huggingface_hub
0fbfbf1 verified
Raw History Blame Contribute Delete
1.17 kB
"""Entry point for running the real Systematic Review Tool inside a
Hugging Face Gradio-SDK Space (no Docker required).
Gradio-SDK Spaces just execute this file with `python run_space.py` inside
a Python container that has your requirements.txt installed - it does NOT
require the script to actually build a Gradio interface. We use that to
run our real FastAPI app directly, serving on the port HF expects (7860).
Node/npm are not available in this container, so the frontend must be
built locally first (`npm run build` in frontend/) and its `dist/` folder
uploaded alongside this script - main.py already knows how to serve it
as static files once it finds frontend/dist next to backend/.
"""
import os
import sys
from pathlib import Path
# backend/app is a package (has __init__.py); adding backend/ to sys.path
# lets us import it as "app.main" without restructuring the project.
sys.path.insert(0, str(Path(__file__).parent / "backend"))
import uvicorn
from app.main import app as fastapi_app # noqa: E402 (import after sys.path fix)
if __name__ == "__main__":
port = int(os.environ.get("PORT", 7860))
uvicorn.run(fastapi_app, host="0.0.0.0", port=port)