|
from flask import Flask, jsonify |
|
from simple_salesforce import Salesforce |
|
|
|
app = Flask(__name__) |
|
print("Flask app is running...") |
|
|
|
|
|
SF_USERNAME = "[email protected]" |
|
SF_PASSWORD = "Sati@1020" |
|
SF_SECURITY_TOKEN = "sSSjyhInIsUohKpG8sHzty2q" |
|
SF_DOMAIN = "login" |
|
|
|
|
|
sf = Salesforce(username=SF_USERNAME, password=SF_PASSWORD, security_token=SF_SECURITY_TOKEN, domain=SF_DOMAIN) |
|
|
|
@app.route('/get_menu', methods=['GET']) |
|
def get_menu(): |
|
query = "SELECT Name, Price__c, Description__c, Image_URL__c FROM Menu_Item__c" |
|
menu_items = sf.query(query)['records'] |
|
|
|
menu_data = [ |
|
{ |
|
"name": item["Name"], |
|
"price": item["Price__c"], |
|
"description": item.get("Description__c", ""), |
|
"image": item.get("Image1__c", "") |
|
} |
|
for item in menu_items |
|
] |
|
|
|
return jsonify(menu_data) |
|
|
|
if __name__ == "__main__": |
|
app.run(host="0.0.0.0", port=7860, debug=True) |
|
|