feat: DrHider MVP — two-pass document obfuscation service
Deploy contracts-flask / validate (push) Successful in 0s

This commit is contained in:
2026-06-29 14:28:27 +04:00
parent c452742271
commit 4956ca1670
4 changed files with 681 additions and 0 deletions
+49
View File
@@ -103,6 +103,55 @@ def ci_cd():
return render_template("ci-cd.html")
@app.route("/DrHider")
def drhider():
return render_template("drhider.html")
@app.route("/api/drhider", methods=["POST"])
def api_drhider():
"""Обфускация: файлы → ZIP с обезличенными копиями + mapping.csv."""
import io
import zipfile
from flask import send_file
uploaded = request.files.getlist("files")
if not uploaded:
return jsonify({"ok": False, "error": "Нет файлов"}), 400
files = []
for f in uploaded:
if not f.filename:
continue
content = f.read()
files.append((f.filename, content, f.content_type or ""))
if not files:
return jsonify({"ok": False, "error": "Нет файлов"}), 400
try:
from services.drhider import obfuscate_files
from services.llm_client import HttpxLLMClient
# LLM-клиент для NER (если настроен)
llm = HttpxLLMClient(LLM_URL, LLM_KEY, LLM_MODEL) if LLM_KEY else None
zip_data, csv_data = obfuscate_files(files, llm_client=llm)
buf = io.BytesIO()
buf.write(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
@app.route("/health")
def health():
return {"ok": True, "service": "contracts-flask"}