# 5️⃣ Run the dev server uvicorn app.main:app --reload Open http://127.0.0.1:8000/docs – you’ll see the interactive Swagger UI. # Dockerfile FROM python:3.11-slim
import httpx from fastapi import HTTPException, status from .config import settings heretic webdl
CMD ["gunicorn", "-k", "uvicorn
import uvicorn from fastapi import FastAPI, HTTPException, Request, status from fastapi.responses import StreamingResponse, JSONResponse from pydantic import BaseModel, HttpUrl, validator # 5️⃣ Run the dev server uvicorn app
def _check_rate_limit(ip: str) -> None: now = datetime.utcnow() window_start = now - timedelta(minutes=1) status from fastapi.responses import StreamingResponse
async with httpx.AsyncClient(follow_redirects=True, timeout=30) as client: try: # `stream=True` gives us an async iterator over the body async with client.stream("GET", url) as resp: # Basic sanity checks if resp.status_code != 200: raise HTTPException( status_code=status.HTTP_502_BAD_GATEWAY, detail=f"Remote server returned resp.status_code", )
# Load .env only when running locally (Heroku injects env vars itself) if Path(".env").exists(): load_dotenv(".env")