From 709603c372b7367d4720d6d6ffde4a2c10b7159f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Mon, 29 Jun 2026 15:15:27 +0400 Subject: [PATCH] =?UTF-8?q?fix:=20DrHider=20=E2=80=94=20direct=20processin?= =?UTF-8?q?g,=20no=20proxy,=20just=20ZIP=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/app.py | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/site/app.py b/site/app.py index a70478a..d9200fe 100644 --- a/site/app.py +++ b/site/app.py @@ -110,38 +110,27 @@ def drhider(): @app.route("/api/drhider", methods=["POST"]) def api_drhider(): - """Обфускация: файлы → VM (LLM-NER) → ZIP.""" - import httpx + """Обфускация: файлы → LLM-NER → ZIP.""" + import io from flask import send_file + from services.drhider import obfuscate_files uploaded = request.files.getlist("files") if not uploaded: return jsonify({"ok": False, "error": "Нет файлов"}), 400 - # Отправляем файлы на VM - try: - files_data = [] - for f in uploaded: - if f.filename: - files_data.append(("files", (f.filename, f.read(), f.content_type or ""))) + files = [(f.filename, f.read(), f.content_type or "") for f in uploaded if f.filename] + if not files: + return jsonify({"ok": False, "error": "Нет файлов"}), 400 - with httpx.Client(timeout=300) as client: - resp = client.post(f"{VM_API}/api/drhider", files=files_data) - resp.raise_for_status() - except httpx.HTTPStatusError as e: - try: - detail = e.response.json().get("error", str(e)) - except Exception: - detail = str(e) - return jsonify({"ok": False, "error": detail}), 500 + try: + zip_data, _csv = obfuscate_files(files) + buf = io.BytesIO(zip_data) + buf.seek(0) + return send_file(buf, mimetype="application/zip", as_attachment=True, download_name="drhider_output.zip") except Exception as e: return jsonify({"ok": False, "error": str(e)}), 500 - import io - buf = io.BytesIO(resp.content) - buf.seek(0) - return send_file(buf, mimetype="application/zip", as_attachment=True, download_name="drhider_output.zip") - @app.route("/health") def health():