simikkk's picture
Upload 36 files
16e1aa7 verified
Raw
History Blame Contribute Delete
907 Bytes
"""
Entry point for Hugging Face Spaces running the **Gradio SDK** (free CPU
basic tier, no Docker needed).
Why this file exists instead of just `app.py`: the project already has a
package called `app/` (all the FastAPI/business logic lives there). Python
can't have a module `app.py` and a package `app/` in the same directory, so
this file is named `server.py` instead, and the Space is configured (via the
`app_file: server.py` line in README.md's metadata block) to run this file.
It imports the fully-wired FastAPI app (with the Gradio UI already mounted
onto it in app/main.py) and serves it with uvicorn on port 7860, which is
the port Hugging Face Spaces expects regardless of which SDK you pick.
"""
import os
import uvicorn
from app.main import app as fastapi_app
if __name__ == "__main__":
port = int(os.environ.get("PORT", 7860))
uvicorn.run(fastapi_app, host="0.0.0.0", port=port)