@bp.route("/download/gr-3108-core", methods=["GET"]) @login_required # <‑‑ remove/comment if public download is ok def download_gr_3108_core(): """ Serve GR‑3108‑Core.pdf. - Supports HTTP Range requests out‑of‑the‑box via Flask's `send_file`. - Logs every successful request (you can hook into any logger). """ filename = "GR-3108-Core.pdf" path = get_pdf_path(filename)

const API_ENDPOINT = '/api/v1/download/gr-3108-core';

# 2️⃣ Test locally python run.py # → http://localhost:5000/api/v1/download/gr-3108-core

# Cache for a day – browsers can keep it locally max_age = current_app.config.get("PDF_MAX_AGE", 86400) expires = datetime.utcnow() + timedelta(seconds=max_age) response.headers["Cache-Control"] = f"public, max-age=max_age" response.headers["Expires"] = expires.strftime("%a, %d %b %Y %H:%M:%S GMT")

# OPTIONAL: clean‑up tasks after response is sent @after_this_request def add_custom_headers(r): # Example: custom analytics header r.headers["X-Download-Id"] = request.headers.get("X-Request-ID", "N/A") return r