Atualizar app/app.py

This commit is contained in:
2026-08-19 21:45:41 -03:00
parent 8a973ee7a7
commit 71db35edc6
+37
View File
@@ -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/<cid>", 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