Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import os
|
2 |
-
from flask import Flask, render_template, request
|
3 |
from simple_salesforce import Salesforce
|
4 |
|
5 |
# Initialize Flask app
|
@@ -8,12 +8,28 @@ app = Flask(__name__)
|
|
8 |
# Securely store the secret key
|
9 |
app.secret_key = os.environ.get('FLASK_SECRET_KEY', 'your_secret_key')
|
10 |
|
11 |
-
#
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
@app.route("/")
|
18 |
def home():
|
19 |
return redirect("/menu") # Redirect home page to menu page
|
@@ -39,7 +55,7 @@ def menu():
|
|
39 |
except Exception as e:
|
40 |
food_items = []
|
41 |
categories = []
|
42 |
-
print(f"
|
43 |
|
44 |
return render_template("menu.html", food_items=food_items, categories=categories, selected_category=selected_category)
|
45 |
|
|
|
1 |
import os
|
2 |
+
from flask import Flask, render_template, request, redirect
|
3 |
from simple_salesforce import Salesforce
|
4 |
|
5 |
# Initialize Flask app
|
|
|
8 |
# Securely store the secret key
|
9 |
app.secret_key = os.environ.get('FLASK_SECRET_KEY', 'your_secret_key')
|
10 |
|
11 |
+
# Fetch Salesforce credentials from environment variables
|
12 |
+
SF_USERNAME = os.environ.get(diggavalli98@gmail.com)
|
13 |
+
SF_PASSWORD = os.environ.get(Sati@1020)
|
14 |
+
SF_SECURITY_TOKEN = os.environ.get(sSSjyhInIsUohKpG8sHzty2q)
|
15 |
+
|
16 |
+
# Debugging: Print whether credentials exist
|
17 |
+
if not SF_USERNAME or not SF_PASSWORD or not SF_SECURITY_TOKEN:
|
18 |
+
print("❌ ERROR: Missing Salesforce credentials. Set SF_USERNAME, SF_PASSWORD, and SF_SECURITY_TOKEN as environment variables.")
|
19 |
+
exit(1)
|
20 |
+
|
21 |
+
# Establish Salesforce connection
|
22 |
+
try:
|
23 |
+
sf = Salesforce(
|
24 |
+
username=diggavalli98@gmail.com,
|
25 |
+
password=Sati@1020,
|
26 |
+
security_token=sSSjyhInIsUohKpG8sHzty2q
|
27 |
+
)
|
28 |
+
print("✅ Salesforce connection established successfully.")
|
29 |
+
except Exception as e:
|
30 |
+
print(f"❌ ERROR: Failed to connect to Salesforce: {str(e)}")
|
31 |
+
exit(1)
|
32 |
+
|
33 |
@app.route("/")
|
34 |
def home():
|
35 |
return redirect("/menu") # Redirect home page to menu page
|
|
|
55 |
except Exception as e:
|
56 |
food_items = []
|
57 |
categories = []
|
58 |
+
print(f"❌ ERROR: Fetching data from Salesforce failed: {e}")
|
59 |
|
60 |
return render_template("menu.html", food_items=food_items, categories=categories, selected_category=selected_category)
|
61 |
|