From 71db35edc6dc8f14c920c25be5f0c165b9ba2e37 Mon Sep 17 00:00:00 2001 From: Renato Rosa Date: Wed, 19 Aug 2026 21:45:41 -0300 Subject: [PATCH] Atualizar app/app.py --- app/app.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/app/app.py b/app/app.py index bae74dc..bf807a6 100644 --- a/app/app.py +++ b/app/app.py @@ -859,6 +859,43 @@ def vision(cid): return jsonify({"status": "ok", "description": description}) +# =========== +# IO + +from io_excel import convert_excel + +@app.route("/api/import_excel/", methods=["POST"]) +@login_required +def import_excel(cid): + file = request.files.get("file") + if not file: + return jsonify({"error": "No file"}), 400 + + ext = file.filename.lower().split(".")[-1] + if ext not in ["xlsx", "xls", "ods"]: + return jsonify({"error": "Unsupported format"}), 400 + + temp_path = f"/data/{uuid.uuid4()}.{ext}" + file.save(temp_path) + + tsv = convert_excel(temp_path) + + db = SessionLocal() + msg = Message( + id=str(uuid.uuid4()), + conversation_id=cid, + role="user", + content=f"```\n{tsv}\n```" + ) + db.add(msg) + db.commit() + db.close() + + return jsonify({"status": "ok"}) + + +# ================ +# TASKS from tasks import generate_task