From 40d670fc9a1e29bafe9d3a97e98231d129362c65 Mon Sep 17 00:00:00 2001 From: "Timothy Farrell (aider)" Date: Mon, 15 Jul 2024 11:24:18 -0500 Subject: [PATCH] Removed redundant delete_temp_file function in app.py, using tasks.delete_temp_file instead. --- app.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app.py b/app.py index 902c832..c1d3b8e 100644 --- a/app.py +++ b/app.py @@ -3,7 +3,7 @@ import tempfile import os # Assuming Celery is already set up and imported correctly in the project. -from celery import shared_task # Import your Celery instance here. +from tasks import delete_temp_file # Import your Celery task here. app = FastAPI() @@ -17,12 +17,7 @@ async def upload_file(file: UploadFile = File(...)): with open(temp_file_path, 'wb') as f: f.write(contents) - # Call a Celery task that deletes the file after processing. + # Call the Celery task that deletes the file after processing. delete_temp_file.delay(temp_file_path) # Assuming this is your Celery task name. return {"filename": file.filename} - -# Define the Celery task to delete the temporary file -@shared_task -def delete_temp_file(file_path): - os.remove(file_path)