lokesh341 commited on
Commit
ca53ea8
·
verified ·
1 Parent(s): a40aeaa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -29,7 +29,7 @@ try:
29
  except Exception as e:
30
  print(f"❌ Failed to connect to Salesforce: {str(e)}")
31
 
32
- # ✅ HOME ROUTE (Simplified - Renders index.html)
33
  @app.route("/", methods=["GET"])
34
  def home():
35
  return render_template("index.html")
@@ -68,7 +68,7 @@ def login():
68
  print("➡ Login API hit")
69
  data = request.json
70
  if not data or "email" not in data or "phone" not in data:
71
- return jsonify({"error": "Missing email or phone"}), 400
72
 
73
  try:
74
  query = f"SELECT Id, Name FROM Customer_Login__c WHERE Email__c = '{data['email']}' AND Phone_Number__c = '{data['phone']}'"
@@ -77,11 +77,17 @@ def login():
77
  if result["totalSize"] > 0:
78
  user = result["records"][0]
79
  session["customer_id"] = user["Id"] # Store in session
80
- return jsonify({"success": True, "message": "Login successful", "customer_id": user["Id"], "name": user["Name"]})
 
 
 
 
 
 
81
  else:
82
- return jsonify({"error": "Invalid login credentials"}), 401
83
  except Exception as e:
84
- return jsonify({"error": f"Login failed: {str(e)}"}), 500)
85
 
86
  # ✅ MENU API: Fetch Menu Items from Salesforce
87
  @app.route("/menu", methods=["GET"])
 
29
  except Exception as e:
30
  print(f"❌ Failed to connect to Salesforce: {str(e)}")
31
 
32
+ # ✅ HOME ROUTE (Loads `index.html`)
33
  @app.route("/", methods=["GET"])
34
  def home():
35
  return render_template("index.html")
 
68
  print("➡ Login API hit")
69
  data = request.json
70
  if not data or "email" not in data or "phone" not in data:
71
+ return jsonify({"error": "Missing email or phone"}), 400
72
 
73
  try:
74
  query = f"SELECT Id, Name FROM Customer_Login__c WHERE Email__c = '{data['email']}' AND Phone_Number__c = '{data['phone']}'"
 
77
  if result["totalSize"] > 0:
78
  user = result["records"][0]
79
  session["customer_id"] = user["Id"] # Store in session
80
+ return jsonify({
81
+ "success": True,
82
+ "message": "Login successful",
83
+ "customer_id": user["Id"],
84
+ "name": user["Name"]
85
+ })
86
+
87
  else:
88
+ return jsonify({"error": "Invalid login credentials"}), 401
89
  except Exception as e:
90
+ return jsonify({"error": f"Login failed: {str(e)}"}), 500
91
 
92
  # ✅ MENU API: Fetch Menu Items from Salesforce
93
  @app.route("/menu", methods=["GET"])