Changed to workdir variable

This commit is contained in:
Christian Krakau-Louis
2025-02-11 22:01:42 +01:00
parent 3afc6746b8
commit fb217a8d8f
5 changed files with 47 additions and 22 deletions
+7 -3
View File
@@ -1,8 +1,9 @@
#!/usr/bin/env python3
from fastapi import FastAPI, HTTPException
from .tasks.upload_to_s3 import upload_to_s3
import os
from fastapi import FastAPI, HTTPException
from app.config import settings
from app.tasks.upload_to_s3 import upload_to_s3
app = FastAPI(title="Document Processing API")
@@ -17,9 +18,12 @@ def process(file_path: str):
This enqueues the first task (upload_to_s3), which handles the full pipeline.
"""
# If file_path is not absolute, treat it as relative to settings.workdir.
if not os.path.isabs(file_path):
file_path = os.path.join(settings.workdir, file_path)
if not os.path.exists(file_path):
raise HTTPException(status_code=400, detail=f"File {file_path} not found.")
task = upload_to_s3.delay(file_path)
return {"task_id": task.id, "status": "queued"}