Atualizar app/app.py
This commit is contained in:
+37
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user