Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,33 @@
|
|
1 |
-
from flask import Flask,
|
|
|
2 |
|
3 |
-
app = Flask(__name__
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
if __name__ == "__main__":
|
10 |
app.run(host="0.0.0.0", port=7860, debug=True)
|
11 |
-
|
|
|
1 |
+
from flask import Flask, jsonify
|
2 |
+
from simple_salesforce import Salesforce
|
3 |
|
4 |
+
app = Flask(__name__)
|
5 |
|
6 |
+
# Salesforce credentials
|
7 |
+
SF_USERNAME = "[email protected]"
|
8 |
+
SF_PASSWORD = "Sati@1020"
|
9 |
+
SF_SECURITY_TOKEN = "sSSjyhInIsUohKpG8sHzty2q"
|
10 |
+
SF_DOMAIN = "login" # Use "test" if using a sandbox
|
11 |
+
|
12 |
+
# Connect to Salesforce
|
13 |
+
sf = Salesforce(username=SF_USERNAME, password=SF_PASSWORD, security_token=SF_SECURITY_TOKEN, domain=SF_DOMAIN)
|
14 |
+
|
15 |
+
@app.route('/get_menu', methods=['GET'])
|
16 |
+
def get_menu():
|
17 |
+
query = "SELECT Name, Price__c, Description__c, Image_URL__c FROM Menu_Item__c"
|
18 |
+
menu_items = sf.query(query)['records']
|
19 |
+
|
20 |
+
menu_data = [
|
21 |
+
{
|
22 |
+
"name": item["Name"],
|
23 |
+
"price": item["Price__c"],
|
24 |
+
"description": item.get("Description__c", ""),
|
25 |
+
"image": item.get("Image1__c", "")
|
26 |
+
}
|
27 |
+
for item in menu_items
|
28 |
+
]
|
29 |
+
|
30 |
+
return jsonify(menu_data)
|
31 |
|
32 |
if __name__ == "__main__":
|
33 |
app.run(host="0.0.0.0", port=7860, debug=True)
|
|