from .downloader import stream_remote_file from .config import settings
class Settings: # ---- security / abuse limits ------------------------------------------------- MAX_CONTENT_LENGTH = int(os.getenv("MAX_CONTENT_LENGTH", "104857600")) # 100 MiB # Optional whitelist (comma‑separated). If empty → allow any domain. WHITELISTED_DOMAINS = set( filter(None, os.getenv("WHITELISTED_DOMAINS", "").split(",")) ) # Rate limiting – simple token bucket stored in memory (good enough for free tier) RATE_LIMIT = int(os.getenv("RATE_LIMIT", "10")) # requests per minute per IP heretic webdl
# Guess a filename from the URL if the remote server doesn't set one filename = payload.url.path.split("/")[-1] or "downloaded_file" heretic webdl
heroku-webdl/ ├─ app/ │ ├─ __init__.py │ ├─ main.py # FastAPI entry point │ ├─ downloader.py # Core download logic │ └─ config.py # Settings (env‑vars) ├─ tests/ │ └─ test_download.py ├─ Dockerfile # (optional) for local dev / CI ├─ requirements.txt ├─ runtime.txt # tells Heroku which Python version ├─ Procfile # Heroku process declaration ├─ .gitignore └─ .env.example # template for local dev heretic webdl