Yaswanth56 commited on
Commit
fba6dac
·
verified ·
1 Parent(s): 3379a05

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -43,20 +43,20 @@ def get_ingredients():
43
 
44
  dietary_preference = request.json.get('dietary_preference', '').lower()
45
 
46
- # SOQL query based on dietary preference
47
  if dietary_preference == 'veg':
48
- soql = "SELECT Sector_Detail_Name__c FROM Sector_Detail__c WHERE Category__c IN ('Veg', 'Both') LIMIT 200"
49
  elif dietary_preference == 'non-vegetarian':
50
- soql = "SELECT Sector_Detail_Name__c FROM Sector_Detail__c WHERE Category__c IN ('Non-Veg', 'Both') LIMIT 200"
51
  else:
52
- soql = "SELECT Sector_Detail_Name__c FROM Sector_Detail__c LIMIT 200"
53
 
54
  try:
55
  result = sf.query(soql)
56
- ingredients = [record['Sector_Detail_Name__c'] for record in result['records'] if 'Sector_Detail_Name__c' in record]
57
  return jsonify({"ingredients": ingredients})
58
  except Exception as e:
59
  return jsonify({"error": f"Failed to fetch ingredients: {str(e)}"}), 500
60
 
61
  if __name__ == '__main__':
62
- app.run(debug=True, host='0.0.0.0', port=7860)
 
43
 
44
  dietary_preference = request.json.get('dietary_preference', '').lower()
45
 
46
+ # SOQL query based on dietary preference with corrected field name 'Name'
47
  if dietary_preference == 'veg':
48
+ soql = "SELECT Name FROM Sector_Detail__c WHERE Category__c IN ('Veg', 'Both') LIMIT 200"
49
  elif dietary_preference == 'non-vegetarian':
50
+ soql = "SELECT Name FROM Sector_Detail__c WHERE Category__c IN ('Non-Veg', 'Both') LIMIT 200"
51
  else:
52
+ soql = "SELECT Name FROM Sector_Detail__c LIMIT 200"
53
 
54
  try:
55
  result = sf.query(soql)
56
+ ingredients = [record['Name'] for record in result['records'] if 'Name' in record]
57
  return jsonify({"ingredients": ingredients})
58
  except Exception as e:
59
  return jsonify({"error": f"Failed to fetch ingredients: {str(e)}"}), 500
60
 
61
  if __name__ == '__main__':
62
+ app.run(debug=True, host='0.0.0.0', port=7860)