fix: DrHider — direct processing, no proxy, just ZIP fix
Deploy contracts-flask / validate (push) Successful in 0s
Deploy contracts-flask / validate (push) Successful in 0s
This commit is contained in:
+11
-22
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user