refactor: deploy/ только для Flask-ВМ + HISTORY.md

This commit is contained in:
2026-06-27 19:44:53 +04:00
parent ec5e23589b
commit 5863906a4e
61 changed files with 120 additions and 4805 deletions
+35
View File
@@ -0,0 +1,35 @@
"""Unzip service — extract files from ZIP archive (no DB, no parse)."""
import zipfile, io, base64
def handle_unzip(rfile, content_length):
"""Parse ZIP upload, return list of extracted files as base64."""
body = rfile.read(content_length)
# Find file data in raw multipart
idx = body.find(b"\r\n\r\n")
if idx < 0:
return {"ok": False, "error": "invalid multipart"}
raw = body[idx + 4:]
zip_start = raw.find(b"PK\x03\x04")
if zip_start < 0:
return {"ok": False, "error": "not a ZIP file"}
zip_data = raw[zip_start:]
files = []
with zipfile.ZipFile(io.BytesIO(zip_data)) as zf:
for name in zf.namelist():
if name.endswith("/"):
continue
data = zf.read(name)
ext = name.rsplit(".", 1)[-1].lower() if "." in name else ""
files.append({
"filename": name,
"data_b64": base64.b64encode(data).decode(),
"ext": ext,
"size": len(data),
})
return {"ok": True, "files": files}