Spaces:
Sleeping
Sleeping
WebashalarForML
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -47,7 +47,7 @@ def index():
|
|
47 |
logging.info(f"Accessed index page, uploaded files: {uploaded_files}")
|
48 |
return render_template('index.html', uploaded_files=uploaded_files)
|
49 |
|
50 |
-
@app.route('/upload', methods=['
|
51 |
def upload_file():
|
52 |
if 'files' not in request.files:
|
53 |
flash('No file part')
|
@@ -97,15 +97,22 @@ def remove_file():
|
|
97 |
@app.route('/reset_upload')
|
98 |
def reset_upload():
|
99 |
"""Reset the uploaded file and the processed data."""
|
100 |
-
|
101 |
if uploaded_file:
|
102 |
-
for filename in
|
103 |
-
os.
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
106 |
flash('Files successfully removed')
|
|
|
107 |
else:
|
108 |
-
flash('No file to remove.')
|
|
|
109 |
return redirect(url_for('index'))
|
110 |
|
111 |
@app.route('/process', methods=['GET','POST'])
|
|
|
47 |
logging.info(f"Accessed index page, uploaded files: {uploaded_files}")
|
48 |
return render_template('index.html', uploaded_files=uploaded_files)
|
49 |
|
50 |
+
@app.route('/upload', methods=['POST'])
|
51 |
def upload_file():
|
52 |
if 'files' not in request.files:
|
53 |
flash('No file part')
|
|
|
97 |
@app.route('/reset_upload')
|
98 |
def reset_upload():
|
99 |
"""Reset the uploaded file and the processed data."""
|
100 |
+
uploaded_files = session.get('uploaded_files', [])
|
101 |
if uploaded_file:
|
102 |
+
for filename in uploaded_files:
|
103 |
+
file_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
|
104 |
+
if os.path.exists(file_path):
|
105 |
+
os.remove(file_path)
|
106 |
+
logging.info(f"Removed file: {filename}")
|
107 |
+
else:
|
108 |
+
logging.warning(f"File not found for removal: {file_path}") # More specific log
|
109 |
+
|
110 |
+
session.pop('uploaded_files', None)
|
111 |
flash('Files successfully removed')
|
112 |
+
logging.info("All uploaded files removed")
|
113 |
else:
|
114 |
+
flash('No file to remove.')
|
115 |
+
logging.warning("File not found for removal")
|
116 |
return redirect(url_for('index'))
|
117 |
|
118 |
@app.route('/process', methods=['GET','POST'])
|