YALCINKAYA commited on
Commit
e013ea6
·
verified ·
1 Parent(s): cdb2e51

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -112,7 +112,7 @@ def list_uploaded_files():
112
 
113
  return jsonify({"files": files}), 200
114
  except Exception as e:
115
- return jsonify({"error": f"Error listing files: {e}"}), 500
116
 
117
  @app.route("/upload", methods=["POST"])
118
  def handle_upload():
@@ -131,19 +131,19 @@ def handle_upload():
131
  if not os.access(UPLOAD_DIR, os.W_OK): # Check write permissions
132
  os.chmod(UPLOAD_DIR, 0o777)
133
  except PermissionError as e:
134
- return jsonify({"error": f"Permission error with upload directory: {e}"}), 500
135
 
136
  try:
137
  # Save the file to the upload directory
138
  file.save(file_path)
139
  except Exception as e:
140
- return jsonify({"error": f"Error saving file: {e}"}), 500
141
 
142
  # Process the document using the upload_document function
143
  try:
144
  upload_document(file_path, bertmodel) # Assuming 'bertmodel' is defined elsewhere
145
  except Exception as e:
146
- return jsonify({"error": f"Error processing file: {e}"}), 500
147
 
148
  # Return success response
149
  return jsonify({"message": "File uploaded and processed successfully"}), 200
 
112
 
113
  return jsonify({"files": files}), 200
114
  except Exception as e:
115
+ return jsonify({"error": f"Error listing files: {e}"}), 504
116
 
117
  @app.route("/upload", methods=["POST"])
118
  def handle_upload():
 
131
  if not os.access(UPLOAD_DIR, os.W_OK): # Check write permissions
132
  os.chmod(UPLOAD_DIR, 0o777)
133
  except PermissionError as e:
134
+ return jsonify({"error": f"Permission error with upload directory: {e}"}), 501
135
 
136
  try:
137
  # Save the file to the upload directory
138
  file.save(file_path)
139
  except Exception as e:
140
+ return jsonify({"error": f"Error saving file: {e}"}), 502
141
 
142
  # Process the document using the upload_document function
143
  try:
144
  upload_document(file_path, bertmodel) # Assuming 'bertmodel' is defined elsewhere
145
  except Exception as e:
146
+ return jsonify({"error": f"Error processing file: {e}"}), 503
147
 
148
  # Return success response
149
  return jsonify({"message": "File uploaded and processed successfully"}), 200