Yaswanth56 commited on
Commit
7c91f9b
·
verified ·
1 Parent(s): 320df65

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -40,10 +40,10 @@ def get_ingredients():
40
 
41
  if dietary_preference == 'vegetable':
42
  logging.debug("Fetching ingredients for Vegetables...")
43
- soql = "SELECT Name, Image_URL__c FROM Sector_Detail__c WHERE Category__c IN ('Veg') LIMIT 200"
44
  elif dietary_preference == 'non-vegetarian':
45
- logging.debug(f"Fetching ingredients for Non-Vegetarian...")
46
- soql = "SELECT Name, Image_URL__c FROM Sector_Detail__c WHERE Category__c IN ('Non-Veg') LIMIT 200"
47
  else:
48
  logging.debug("Invalid dietary preference received.")
49
  return jsonify({"error": "Invalid dietary preference."}), 400
@@ -51,10 +51,10 @@ def get_ingredients():
51
  try:
52
  result = sf.query(soql)
53
  ingredients = [
54
- {"name": record['Name'], "image_url": record.get('Image_URL__c', '')}
55
  for record in result['records'] if 'Name' in record
56
  ]
57
- logging.debug(f"Fetched {len(ingredients)} ingredients.")
58
  return jsonify({"ingredients": ingredients})
59
  except Exception as e:
60
  logging.error(f"Error while fetching ingredients: {str(e)}")
@@ -92,4 +92,4 @@ def submit_ingredients():
92
  return jsonify({'success': True})
93
 
94
  if __name__ == '__main__':
95
- app.run(debug=True, host='0.0.0.0', port=7860)
 
40
 
41
  if dietary_preference == 'vegetable':
42
  logging.debug("Fetching ingredients for Vegetables...")
43
+ soql = "SELECT Name, Image_URL__c, Category__c FROM Sector_Detail__c WHERE Category__c = 'Veg' LIMIT 200"
44
  elif dietary_preference == 'non-vegetarian':
45
+ logging.debug("Fetching ingredients for Non-Vegetarian...")
46
+ soql = "SELECT Name, Image_URL__c, Category__c FROM Sector_Detail__c WHERE Category__c = 'Non-Veg' LIMIT 200"
47
  else:
48
  logging.debug("Invalid dietary preference received.")
49
  return jsonify({"error": "Invalid dietary preference."}), 400
 
51
  try:
52
  result = sf.query(soql)
53
  ingredients = [
54
+ {"name": record['Name'], "image_url": record.get('Image_URL__c', ''), "category": record.get('Category__c', '')}
55
  for record in result['records'] if 'Name' in record
56
  ]
57
+ logging.debug(f"Fetched ingredients: {[ing['name'] + ' (' + ing['category'] + ')' for ing in ingredients]}")
58
  return jsonify({"ingredients": ingredients})
59
  except Exception as e:
60
  logging.error(f"Error while fetching ingredients: {str(e)}")
 
92
  return jsonify({'success': True})
93
 
94
  if __name__ == '__main__':
95
+ app.run(debug=True, host='0.0.0.0', port=7860)