Files
drhider/site/routes/download_bp.py
T

22 lines
696 B
Python

"""
GET /api/download/{sid} — скачать ZIP и удалить сессию.
После этого вызова — всё чисто, памяти ноль.
"""
import io
from flask import Blueprint, send_file, jsonify
from session import get_result, cleanup
download_bp = Blueprint("download", __name__, url_prefix="/api")
@download_bp.route("/download/<sid>", methods=["GET"])
def download(sid):
zip_data = get_result(sid)
if zip_data is None:
return jsonify({"ok": False, "error": "Not found"}), 404
cleanup(sid)
return send_file(io.BytesIO(zip_data), mimetype="application/zip",
as_attachment=True, download_name="drhider_output.zip")