Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -53,12 +53,15 @@ def index():
|
|
53 |
logging.info(f"Accessed index page, uploaded files: {uploaded_files}")
|
54 |
return render_template('index.html', uploaded_files=uploaded_files)
|
55 |
|
56 |
-
@app.route('/upload', methods=['POST'])
|
57 |
def upload_file():
|
58 |
try:
|
59 |
-
|
|
|
|
|
|
|
60 |
if 'files' not in request.files:
|
61 |
-
print("request.files-------------->",request.files)
|
62 |
flash('No file part')
|
63 |
logging.warning("No file part found in the request")
|
64 |
return jsonify({'message': "No file part found in the request"})
|
@@ -74,19 +77,16 @@ def upload_file():
|
|
74 |
if file:
|
75 |
filename = file.filename
|
76 |
file_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
|
77 |
-
print("file_path-------------->",file_path)
|
78 |
-
# Save the file
|
79 |
try:
|
80 |
file.save(file_path)
|
81 |
uploaded_files.append(filename)
|
82 |
logging.info(f"Uploaded file: {filename} at {file_path}")
|
83 |
-
print(f"Uploaded file---------->: {filename} at {file_path}")
|
84 |
except Exception as save_error:
|
85 |
logging.error(f"Error saving file {filename}: {save_error}")
|
86 |
return jsonify({'message': f"Error saving file {filename}"}), 500
|
87 |
|
88 |
-
# session['uploaded_files'] = uploaded_files # Store the uploaded files in session
|
89 |
-
# flash('Files successfully uploaded')
|
90 |
logging.info(f"Files successfully uploaded: {uploaded_files}")
|
91 |
return jsonify({
|
92 |
'message': 'Files successfully uploaded',
|
@@ -95,10 +95,10 @@ def upload_file():
|
|
95 |
|
96 |
except Exception as e:
|
97 |
logging.error(f"An error occurred during file upload: {e}")
|
98 |
-
flash('An error occurred during file upload')
|
99 |
return jsonify({'message': 'File upload failed'}), 500
|
100 |
|
101 |
|
|
|
102 |
@app.route('/remove_file')
|
103 |
def remove_file():
|
104 |
uploaded_files = session.get('uploaded_files', [])
|
|
|
53 |
logging.info(f"Accessed index page, uploaded files: {uploaded_files}")
|
54 |
return render_template('index.html', uploaded_files=uploaded_files)
|
55 |
|
56 |
+
@app.route('/upload', methods=methods=['GET', 'POST'])
|
57 |
def upload_file():
|
58 |
try:
|
59 |
+
print("Request headers:", request.headers)
|
60 |
+
print("Request form:", request.form)
|
61 |
+
print("Request files:", request.files)
|
62 |
+
|
63 |
if 'files' not in request.files:
|
64 |
+
print("request.files-------------->", request.files)
|
65 |
flash('No file part')
|
66 |
logging.warning("No file part found in the request")
|
67 |
return jsonify({'message': "No file part found in the request"})
|
|
|
77 |
if file:
|
78 |
filename = file.filename
|
79 |
file_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
|
80 |
+
print("file_path-------------->", file_path)
|
|
|
81 |
try:
|
82 |
file.save(file_path)
|
83 |
uploaded_files.append(filename)
|
84 |
logging.info(f"Uploaded file: {filename} at {file_path}")
|
85 |
+
print(f"Uploaded file---------->: {filename} at {file_path}")
|
86 |
except Exception as save_error:
|
87 |
logging.error(f"Error saving file {filename}: {save_error}")
|
88 |
return jsonify({'message': f"Error saving file {filename}"}), 500
|
89 |
|
|
|
|
|
90 |
logging.info(f"Files successfully uploaded: {uploaded_files}")
|
91 |
return jsonify({
|
92 |
'message': 'Files successfully uploaded',
|
|
|
95 |
|
96 |
except Exception as e:
|
97 |
logging.error(f"An error occurred during file upload: {e}")
|
|
|
98 |
return jsonify({'message': 'File upload failed'}), 500
|
99 |
|
100 |
|
101 |
+
|
102 |
@app.route('/remove_file')
|
103 |
def remove_file():
|
104 |
uploaded_files = session.get('uploaded_files', [])
|