diff --git a/api/api/views.py b/api/api/views.py index 6cb298c..7769ac5 100644 --- a/api/api/views.py +++ b/api/api/views.py @@ -19,9 +19,16 @@ from freqsplit.input.format_checker import is_supported_format UPLOAD_DIR = "/tmp/freqsplit" # Ensure the temp directory exists -shutil.rmtree(UPLOAD_DIR) os.makedirs(UPLOAD_DIR, exist_ok=True) +# Remove all files inside the directory +for filename in os.listdir(UPLOAD_DIR): + file_path = os.path.join(UPLOAD_DIR, filename) + if os.path.isfile(file_path) or os.path.islink(file_path): + os.unlink(file_path) + elif os.path.isdir(file_path): + shutil.rmtree(file_path) + # Endpoint to ping server @api_view(['GET']) def ping(request):