|
from flask import Flask, jsonify, render_template |
|
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) |
|
|
|
def fetch_menu_items(): |
|
query = "SELECT Name, Image1__c, Image2__c, Ingredients__c, Price__c, Category__c, Section__c FROM Menu_Item__c" |
|
headers = { |
|
"Authorization": f"Bearer {ACCESS_TOKEN}", |
|
"Content-Type": "application/json" |
|
} |
|
response = requests.get(f"{SALESFORCE_URL}?q={query}", headers=headers) |
|
|
|
if response.status_code == 200: |
|
return response.json()["records"] |
|
else: |
|
return [] |
|
|
|
@app.route('/') |
|
def home(): |
|
return render_template('Menu.html') |
|
|
|
@app.route('/get_menu', methods=['GET']) |
|
def get_menu(): |
|
menu_items = fetch_menu_items() |
|
return jsonify(menu_items) |
|
|
|
if __name__ == "__main__": |
|
app.run(host="0.0.0.0", port=7860, debug=True, use_reloader=False) |