Update app.py
Browse files
app.py
CHANGED
@@ -11,19 +11,19 @@ SF_SECURITY_TOKEN = "sSSjyhInIsUohKpG8sHzty2q"
|
|
11 |
SF_DOMAIN = "login" # Use "test" if using a sandbox
|
12 |
|
13 |
# Connect to Salesforce
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
|
16 |
def fetch_menu_items():
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
if response.status_code == 200:
|
25 |
-
return response.json()["records"]
|
26 |
-
else:
|
27 |
return []
|
28 |
|
29 |
@app.route('/')
|
@@ -36,4 +36,4 @@ def get_menu():
|
|
36 |
return jsonify(menu_items)
|
37 |
|
38 |
if __name__ == "__main__":
|
39 |
-
app.run(host="0.0.0.0", port=7860, debug=True, use_reloader=False)
|
|
|
11 |
SF_DOMAIN = "login" # Use "test" if using a sandbox
|
12 |
|
13 |
# Connect to Salesforce
|
14 |
+
try:
|
15 |
+
sf = Salesforce(username=SF_USERNAME, password=SF_PASSWORD, security_token=SF_SECURITY_TOKEN, domain=SF_DOMAIN)
|
16 |
+
print("Connected to Salesforce successfully!")
|
17 |
+
except Exception as e:
|
18 |
+
print(f"Salesforce connection failed: {e}")
|
19 |
|
20 |
def fetch_menu_items():
|
21 |
+
try:
|
22 |
+
query = "SELECT Name, Image1__c, Image2__c, Ingredients__c, Price__c, Category__c, Section__c FROM Menu_Item__c"
|
23 |
+
result = sf.query(query)
|
24 |
+
return result["records"]
|
25 |
+
except Exception as e:
|
26 |
+
print(f"Error fetching menu items: {e}")
|
|
|
|
|
|
|
|
|
27 |
return []
|
28 |
|
29 |
@app.route('/')
|
|
|
36 |
return jsonify(menu_items)
|
37 |
|
38 |
if __name__ == "__main__":
|
39 |
+
app.run(host="0.0.0.0", port=7860, debug=True, use_reloader=False)
|