File size: 1,214 Bytes
d077798
add8335
c9afd96
add8335
802194b
c9afd96
add8335
 
 
 
 
 
 
e0629ed
 
 
 
 
add8335
998b660
e0629ed
 
 
 
 
 
998b660
 
25b37ca
 
 
a3cdc16
add8335
 
998b660
 
c9afd96
889fd00
e0629ed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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)