DSatishchandra commited on
Commit
a0d63bf
·
verified ·
1 Parent(s): a9c64ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -9
app.py CHANGED
@@ -1,28 +1,54 @@
 
 
1
  from flask import Flask, render_template_string, request, jsonify
2
  import speech_recognition as sr
3
  from tempfile import NamedTemporaryFile
4
  import os
5
  import ffmpeg
6
- import logging
7
  from werkzeug.exceptions import BadRequest
8
 
9
  app = Flask(__name__)
10
  logging.basicConfig(level=logging.INFO)
11
 
 
 
 
 
 
 
 
 
 
12
  # Global variables
13
  cart = [] # To store items, quantities, and prices
14
- MENU = {
15
- "Biryanis": {"Chicken Biryani": 250, "Veg Biryani": 200, "Mutton Biryani": 300},
16
- "Starters": {"Chicken Wings": 220, "Paneer Tikka": 180, "Fish Fingers": 250, "Spring Rolls": 160},
17
- "Rotis": {"Butter Naan": 50, "Garlic Naan": 60, "Roti": 40, "Lachha Paratha": 70},
18
- "Main Course": {"Butter Chicken": 300, "Paneer Butter Masala": 250, "Dal Tadka": 200, "Chicken Tikka Masala": 320},
19
- "Drinks": {"Coke": 60, "Sprite": 60, "Mango Lassi": 80, "Masala Soda": 70},
20
- "Desserts": {"Gulab Jamun": 100, "Rasgulla": 90, "Ice Cream": 120, "Brownie with Ice Cream": 180},
21
- }
22
  current_category = None
23
  current_item = None
24
  awaiting_quantity = False
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  # Extract quantity from command (e.g., "two" -> 2, "three" -> 3, etc.)
27
  def extract_quantity(command):
28
  number_words = {
 
1
+ from simple_salesforce import Salesforce
2
+ import logging
3
  from flask import Flask, render_template_string, request, jsonify
4
  import speech_recognition as sr
5
  from tempfile import NamedTemporaryFile
6
  import os
7
  import ffmpeg
 
8
  from werkzeug.exceptions import BadRequest
9
 
10
  app = Flask(__name__)
11
  logging.basicConfig(level=logging.INFO)
12
 
13
+ # Salesforce connection setup
14
+ sf = Salesforce(
15
+ username='diggavalli98@gmail.com',
16
+ password='Sati@1020',
17
+ security_token='sSSjyhInIsUohKpG8sHzty2q',
18
+ consumer_key='3MVG9WVXk15qiz1JbtW1tT9a7Wnkos2RuGamw6p1lC5uPescT5NB2nPygpo6rQ87K1T.zBEn.wR.A6JdgHnIU',
19
+ consumer_secret='A75C6B7801D5D20BED0E46631CF58C4F7FF28E4DAF442FE667553D29C35C0451'
20
+ )
21
+
22
  # Global variables
23
  cart = [] # To store items, quantities, and prices
24
+ MENU = {}
25
+
 
 
 
 
 
 
26
  current_category = None
27
  current_item = None
28
  awaiting_quantity = False
29
 
30
+ # Fetching menu items dynamically from Salesforce
31
+ def get_menu_items():
32
+ menu_items = {}
33
+ # Querying the Menu_Item__c object to fetch details
34
+ query = "SELECT Name, Category__c, Price__c, Ingredients__c FROM Menu_Item__c"
35
+ results = sf.query_all(query)
36
+
37
+ # Organizing the menu items by category
38
+ for record in results['records']:
39
+ category = record['Category__c']
40
+ item_name = record['Name']
41
+ price = record['Price__c']
42
+
43
+ if category not in menu_items:
44
+ menu_items[category] = {}
45
+ menu_items[category][item_name] = price
46
+
47
+ return menu_items
48
+
49
+ # Update global MENU variable
50
+ MENU = get_menu_items()
51
+
52
  # Extract quantity from command (e.g., "two" -> 2, "three" -> 3, etc.)
53
  def extract_quantity(command):
54
  number_words = {