WebashalarForML commited on
Commit
6c1d851
1 Parent(s): c676e89

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -67,8 +67,13 @@ def upload_file():
67
  def remove_file():
68
  uploaded_files = session.get('uploaded_files', [])
69
  for filename in uploaded_files:
70
- os.remove(os.path.join(app.config['UPLOAD_FOLDER'], filename))
71
- logging.info(f"Removed file: {filename}")
 
 
 
 
 
72
  session.pop('uploaded_files', None)
73
  flash('Files successfully removed')
74
  logging.info("All uploaded files removed")
 
67
  def remove_file():
68
  uploaded_files = session.get('uploaded_files', [])
69
  for filename in uploaded_files:
70
+ file_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
71
+ if os.path.exists(file_path): # Check if the file exists before trying to remove it
72
+ os.remove(file_path)
73
+ logging.info(f"Removed file: {filename}")
74
+ else:
75
+ logging.warning(f"File not found for removal: {filename}")
76
+
77
  session.pop('uploaded_files', None)
78
  flash('Files successfully removed')
79
  logging.info("All uploaded files removed")