MenuPage / app.py
dschandra's picture
Update app.py
e0629ed verified
raw
history blame
1.21 kB
from flask import Flask, jsonify, render_template
from simple_salesforce import Salesforce
app = Flask(__name__)
print("Flask app is running...")
# Salesforce credentials
SF_USERNAME = "[email protected]"
SF_PASSWORD = "Sati@1020"
SF_SECURITY_TOKEN = "sSSjyhInIsUohKpG8sHzty2q"
SF_DOMAIN = "login" # Use "test" if using a sandbox
# Connect to Salesforce
try:
sf = Salesforce(username=SF_USERNAME, password=SF_PASSWORD, security_token=SF_SECURITY_TOKEN, domain=SF_DOMAIN)
print("Connected to Salesforce successfully!")
except Exception as e:
print(f"Salesforce connection failed: {e}")
def fetch_menu_items():
try:
query = "SELECT Name, Image1__c, Image2__c, Ingredients__c, Price__c, Category__c, Section__c FROM Menu_Item__c"
result = sf.query(query)
return result["records"]
except Exception as e:
print(f"Error fetching menu items: {e}")
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)