FROM python:3.9-slim # Install dependencies RUN pip install --no-cache-dir fastapi uvicorn # Create the app.py file using a Heredoc to avoid shell syntax errors RUN cat < app.py from fastapi import FastAPI from fastapi.responses import HTMLResponse import time app = FastAPI() @app.get("/ping") async def ping(): return {"status": "pong"} @app.get("/", response_class=HTMLResponse) async def index(): return """ HF Space Ping

Your Latency to Space

0
ms
""" EOF # Hugging Face Spaces use port 7860 EXPOSE 7860 # Run the server CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]