added ui upload route

This commit is contained in:
Christian Krakau-Louis
2025-03-24 17:02:56 +01:00
parent 09db93f353
commit 2891b335b0
2 changed files with 18 additions and 27 deletions
+18 -1
View File
@@ -113,4 +113,21 @@ def process_all_pdfs_in_workdir():
"task_ids": task_ids
}
app.include_router(frontend_router)
app.include_router(frontend_router)
@router.post("/ui-upload")
async def ui_upload(file: UploadFile = File(...)):
# You can store this file in your 'workdir' (like how /process does) or a tmp dir
workdir = "/workdir"
target_path = os.path.join(workdir, file.filename)
try:
with open(target_path, "wb") as f:
content = await file.read()
f.write(content)
except Exception as e:
raise HTTPException(status_code=500, detail=f"Failed to save file: {e}")
# Now you can call your existing Celery flow:
task = upload_to_s3.delay(target_path)
return {"task_id": task.id, "status": "queued"}