Neurolingua commited on
Commit
c67a732
·
verified ·
1 Parent(s): b27c75b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -40,13 +40,12 @@ def whatsapp_webhook():
40
  content_type = request.values.get('MediaContentType0')
41
 
42
  if content_type.startswith('image/'):
 
 
 
 
43
  try:
44
- # Download the image
45
- r = requests.get(media_url)
46
 
47
- # Generate a unique filename
48
- filename = f"{uuid.uuid4()}.jpg"
49
- return filename
50
  filepath = os.path.join(UPLOAD_FOLDER, filename)
51
 
52
  # Save the image
@@ -61,7 +60,7 @@ def whatsapp_webhook():
61
  response_text = "Please specify if you want to detect a pest or a disease."
62
  except Exception as e:
63
  print(f"Error processing image: {e}")
64
- response_text = "Failed to process the image. Please try again."
65
  else:
66
  response_text = "The attached file is not an image. Please send an image for classification."
67
  elif 'bookkeeping' in incoming_msg:
 
40
  content_type = request.values.get('MediaContentType0')
41
 
42
  if content_type.startswith('image/'):
43
+ r = requests.get(media_url)
44
+
45
+ # Generate a unique filename
46
+ filename = f"{uuid.uuid4()}.jpg"
47
  try:
 
 
48
 
 
 
 
49
  filepath = os.path.join(UPLOAD_FOLDER, filename)
50
 
51
  # Save the image
 
60
  response_text = "Please specify if you want to detect a pest or a disease."
61
  except Exception as e:
62
  print(f"Error processing image: {e}")
63
+ response_text = filename
64
  else:
65
  response_text = "The attached file is not an image. Please send an image for classification."
66
  elif 'bookkeeping' in incoming_msg: