From 9bae90e9a077d836e0f834991933eb9f68b94c5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Wed, 17 Jun 2026 22:34:36 +0400 Subject: [PATCH] =?UTF-8?q?=D1=81=D1=8B=D1=80=D0=BE=D0=B9=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B7=D0=B1=D0=BE=D1=80=20JSON=20(regex,=20=D0=B1=D0=B5=D0=B7?= =?UTF-8?q?=20get=5Fjson),=20v1.40?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/app.py | 22 +++++++++++++--------- site/templates/upload.html | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/site/app.py b/site/app.py index 8b6710c..ce41c69 100644 --- a/site/app.py +++ b/site/app.py @@ -142,22 +142,26 @@ class ContractsApp: # ── Загрузка base64 (JSON) ────────────────────────────────── def _upload_json(self): - """Принять файл как base64. Сохранить строкой (без декодирования — быстро).""" + """Принять файл как base64. Без JSON-парсинга — сырой разбор.""" _log("upload_entry", "start") try: - data = request.get_json(silent=True) - _log("upload_json_parsed", f"data={'yes' if data else 'no'} len={len(request.data) if request.data else 0}") - if not data: - return jsonify({"error": "Нет JSON"}), 400 + raw = request.get_data(as_text=True) + import re + m = re.search(r'"data"\s*:\s*"([^"]*)"', raw) + if not m: + return jsonify({"error": "Нет data"}), 400 + b64 = m.group(1) + + m = re.search(r'"filename"\s*:\s*"([^"]*)"', raw) + filename = m.group(1) if m else "" + + m = re.search(r'"cid"\s*:\s*"([^"]*)"', raw) + cid = m.group(1) if m else None - filename = data.get("filename", "") - b64 = data.get("data", "") - _log("upload", f"file={filename} b64={len(b64) if b64 else 0}") if not filename or not b64: return jsonify({"error": "Нет filename или data"}), 400 mime = mimeutil.guess_mime(filename) or "application/octet-stream" - cid = data.get("cid") # Контракт — синхронно (быстро, нужно для следующих загрузок) if not cid: diff --git a/site/templates/upload.html b/site/templates/upload.html index 906e603..7980473 100644 --- a/site/templates/upload.html +++ b/site/templates/upload.html @@ -59,7 +59,7 @@
Nubes - Сверка договоров v1.39 + Сверка договоров v1.40