Heretic Webdl <QUICK – FIX>
WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt
COPY . . ENV PORT=8000 EXPOSE 8000
# System deps RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential && rm -rf /var/lib/apt/lists/* heretic webdl
# Stream the remote file directly back to the caller # We preserve the original content‑type and disposition when possible async def generator(): async for chunk in stream_remote_file(payload.url): yield chunk
settings = Settings() # app/downloader.py import re import urllib.parse from typing import AsyncGenerator WORKDIR /app COPY requirements
# Enforce a size cap – we read the `Content-Length` header when present content_length = resp.headers.get("Content-Length") if content_length and int(content_length) > settings.MAX_CONTENT_LENGTH: raise HTTPException( status_code=status.HTTP_413_REQUEST_ENTITY_TOO_LARGE, detail="Remote file exceeds the allowed size limit.", )
# 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 ENV PORT=8000 EXPOSE 8000 # System deps RUN
# 4️⃣ (optional) set env vars in a .env file cp .env.example .env # edit .env as needed