v0.0.2: split api_bp into upload/process/download modules, Connection: close, upload tests (13 new, 106 total)
Deploy drhider / validate (push) Waiting to run

This commit is contained in:
2026-07-13 09:15:38 +04:00
parent 345448caa4
commit c35e8da357
7 changed files with 387 additions and 97 deletions
+28
View File
@@ -0,0 +1,28 @@
"""
POST /api/upload — загрузить ОДИН файл.
Каждый вызов — новое соединение, передал → закрыл.
Сессия связывает файлы через session_id.
"""
from flask import Blueprint, request, jsonify
from session import create_session, add_file, file_count
upload_bp = Blueprint("upload", __name__, url_prefix="/api")
@upload_bp.route("/upload", methods=["POST"])
def upload():
sid = request.form.get("session", "")
if not sid:
sid = create_session()
uploaded = request.files.getlist("files")
if not uploaded:
return jsonify({"ok": False, "error": "No file"}), 400
f = uploaded[0]
if not f.filename:
return jsonify({"ok": False, "error": "No filename"}), 400
ok = add_file(sid, f.filename, f.read())
if not ok:
return jsonify({"ok": False, "error": "Session not found"}), 404
return jsonify({"ok": True, "session": sid, "count": file_count(sid)})