Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -181,6 +181,24 @@ def download_latest_model():
|
|
181 |
flash(f"Error while downloading the model: {str(e)}", 'error')
|
182 |
return redirect(request.referrer)
|
183 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
# Route to serve uploaded files
|
185 |
'''
|
186 |
@app.route('/uploads/<filename>')
|
|
|
181 |
flash(f"Error while downloading the model: {str(e)}", 'error')
|
182 |
return redirect(request.referrer)
|
183 |
|
184 |
+
@app.route('/remove_file', methods=['POST'])
|
185 |
+
def remove_file():
|
186 |
+
try:
|
187 |
+
file_to_remove = session.get('uploaded_file', None)
|
188 |
+
if file_to_remove:
|
189 |
+
file_path = os.path.join(app.config['UPLOAD_FOLDER'], file_to_remove)
|
190 |
+
if os.path.exists(file_path):
|
191 |
+
os.remove(file_path)
|
192 |
+
flash(f"{file_to_remove} removed successfully.", "success")
|
193 |
+
session.pop('uploaded_file', None)
|
194 |
+
else:
|
195 |
+
flash("File not found.", "error")
|
196 |
+
else:
|
197 |
+
flash("No file selected for removal.", "error")
|
198 |
+
except Exception as e:
|
199 |
+
flash(f"Error while removing file: {str(e)}", "error")
|
200 |
+
return redirect(url_for('index'))
|
201 |
+
|
202 |
# Route to serve uploaded files
|
203 |
'''
|
204 |
@app.route('/uploads/<filename>')
|