fix: DrHider — direct processing, no proxy, just ZIP fix
Deploy contracts-flask / validate (push) Successful in 0s

This commit is contained in:
2026-06-29 15:15:27 +04:00
parent 7f9f7c0e62
commit 709603c372
+11 -22
View File
@@ -110,38 +110,27 @@ def drhider():
@app.route("/api/drhider", methods=["POST"]) @app.route("/api/drhider", methods=["POST"])
def api_drhider(): def api_drhider():
"""Обфускация: файлы → VM (LLM-NER) → ZIP.""" """Обфускация: файлы → LLM-NER → ZIP."""
import httpx import io
from flask import send_file from flask import send_file
from services.drhider import obfuscate_files
uploaded = request.files.getlist("files") uploaded = request.files.getlist("files")
if not uploaded: if not uploaded:
return jsonify({"ok": False, "error": "Нет файлов"}), 400 return jsonify({"ok": False, "error": "Нет файлов"}), 400
# Отправляем файлы на VM files = [(f.filename, f.read(), f.content_type or "") for f in uploaded if f.filename]
try: if not files:
files_data = [] return jsonify({"ok": False, "error": "Нет файлов"}), 400
for f in uploaded:
if f.filename:
files_data.append(("files", (f.filename, f.read(), f.content_type or "")))
with httpx.Client(timeout=300) as client: try:
resp = client.post(f"{VM_API}/api/drhider", files=files_data) zip_data, _csv = obfuscate_files(files)
resp.raise_for_status() buf = io.BytesIO(zip_data)
except httpx.HTTPStatusError as e: buf.seek(0)
try: return send_file(buf, mimetype="application/zip", as_attachment=True, download_name="drhider_output.zip")
detail = e.response.json().get("error", str(e))
except Exception:
detail = str(e)
return jsonify({"ok": False, "error": detail}), 500
except Exception as e: except Exception as e:
return jsonify({"ok": False, "error": str(e)}), 500 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") @app.route("/health")
def health(): def health():