itsLu commited on
Commit
7156c2e
·
1 Parent(s): f149db0

Allow any file key

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -48,12 +48,15 @@ def serve_root_files(filename):
48
  return "File not found", 404
49
 
50
  # 4. Handle Predictions
 
51
  @app.route('/api/classify', methods=['POST'])
52
  def predict():
53
- if 'file' not in request.files:
 
54
  return jsonify({'error': 'No file uploaded'}), 400
55
 
56
- file = request.files['file']
 
57
 
58
  try:
59
  processed_img = prepare_image(file.read())
 
48
  return "File not found", 404
49
 
50
  # 4. Handle Predictions
51
+ # Updated Predict Function - Accepts ANY file name
52
  @app.route('/api/classify', methods=['POST'])
53
  def predict():
54
+ # Check if ANY file was uploaded
55
+ if not request.files:
56
  return jsonify({'error': 'No file uploaded'}), 400
57
 
58
+ # Grab the first file found, regardless of its key name ('file', 'image', 'img', etc.)
59
+ file = next(iter(request.files.values()))
60
 
61
  try:
62
  processed_img = prepare_image(file.read())