nagasurendra commited on
Commit
a637599
·
verified ·
1 Parent(s): 0379c36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -41,15 +41,14 @@ def get_ingredients():
41
  if not sf:
42
  return jsonify({"error": "Failed to connect to Salesforce"}), 500
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 Name, Image_URL__c FROM Sector_Detail__c WHERE Category__c = 'Veg' LIMIT 200"
49
- elif dietary_preference == 'non-vegetarian':
50
  soql = "SELECT Name, Image_URL__c FROM Sector_Detail__c WHERE Category__c = 'Non-Veg' LIMIT 200"
51
  else:
52
- soql = "SELECT Name, Image_URL__c FROM Sector_Detail__c LIMIT 200"
53
 
54
  try:
55
  result = sf.query(soql)
 
41
  if not sf:
42
  return jsonify({"error": "Failed to connect to Salesforce"}), 500
43
 
44
+ dietary_preference = request.json.get('dietary_preference', '').strip().lower()
45
+
 
46
  if dietary_preference == 'veg':
47
  soql = "SELECT Name, Image_URL__c FROM Sector_Detail__c WHERE Category__c = 'Veg' LIMIT 200"
48
+ elif dietary_preference in ['non-vegetarian', 'non veg', 'nonveg']:
49
  soql = "SELECT Name, Image_URL__c FROM Sector_Detail__c WHERE Category__c = 'Non-Veg' LIMIT 200"
50
  else:
51
+ return jsonify({"error": "Invalid dietary preference."}), 400
52
 
53
  try:
54
  result = sf.query(soql)