lokesh341 commited on
Commit
5ef3837
Β·
verified Β·
1 Parent(s): 17b12ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import torch
3
  from flask import Flask, render_template, request, jsonify, redirect, session, url_for
4
  import json
@@ -30,6 +29,13 @@ try:
30
  except Exception as e:
31
  print(f"❌ Failed to connect to Salesforce: {str(e)}")
32
 
 
 
 
 
 
 
 
33
  # βœ… ROUTE: List All Routes for Debugging
34
  @app.route("/routes", methods=["GET"])
35
  def list_routes():
@@ -46,6 +52,7 @@ def home():
46
  # βœ… REGISTER API: Create a new Customer in Salesforce
47
  @app.route("/register", methods=["POST"])
48
  def register():
 
49
  data = request.json
50
  name = data.get("name")
51
  email = data.get("email")
@@ -67,6 +74,7 @@ def register():
67
  # βœ… LOGIN API: Validate user credentials
68
  @app.route("/login", methods=["POST"])
69
  def login():
 
70
  data = request.json
71
  email = data.get("email")
72
  phone_number = data.get("phone")
@@ -90,6 +98,7 @@ def login():
90
  # βœ… MENU API: Fetch menu items from Salesforce
91
  @app.route("/menu", methods=["GET"])
92
  def get_menu():
 
93
  try:
94
  query = "SELECT Name, Price__c, Ingredients__c, Category__c FROM Menu_Item__c"
95
  result = sf.query(query)
@@ -107,11 +116,6 @@ def get_menu():
107
  except Exception as e:
108
  return jsonify({"error": f"Failed to fetch menu: {str(e)}"}), 500
109
 
110
- # βœ… DASHBOARD ROUTE
111
- @app.route("/dashboard", methods=["GET"])
112
- def dashboard():
113
- return render_template("dashboard.html")
114
-
115
  # βœ… START PRODUCTION SERVER
116
  if __name__ == "__main__":
117
  print("βœ… Starting Flask API Server on port 7860...")
 
 
1
  import torch
2
  from flask import Flask, render_template, request, jsonify, redirect, session, url_for
3
  import json
 
29
  except Exception as e:
30
  print(f"❌ Failed to connect to Salesforce: {str(e)}")
31
 
32
+ # βœ… List All Routes at Startup
33
+ @app.before_first_request
34
+ def print_routes():
35
+ print("\nβœ… Available Routes:")
36
+ for rule in app.url_map.iter_rules():
37
+ print(f"➑ {rule}")
38
+
39
  # βœ… ROUTE: List All Routes for Debugging
40
  @app.route("/routes", methods=["GET"])
41
  def list_routes():
 
52
  # βœ… REGISTER API: Create a new Customer in Salesforce
53
  @app.route("/register", methods=["POST"])
54
  def register():
55
+ print("➑ Register API hit")
56
  data = request.json
57
  name = data.get("name")
58
  email = data.get("email")
 
74
  # βœ… LOGIN API: Validate user credentials
75
  @app.route("/login", methods=["POST"])
76
  def login():
77
+ print("➑ Login API hit")
78
  data = request.json
79
  email = data.get("email")
80
  phone_number = data.get("phone")
 
98
  # βœ… MENU API: Fetch menu items from Salesforce
99
  @app.route("/menu", methods=["GET"])
100
  def get_menu():
101
+ print("➑ Menu API hit")
102
  try:
103
  query = "SELECT Name, Price__c, Ingredients__c, Category__c FROM Menu_Item__c"
104
  result = sf.query(query)
 
116
  except Exception as e:
117
  return jsonify({"error": f"Failed to fetch menu: {str(e)}"}), 500
118
 
 
 
 
 
 
119
  # βœ… START PRODUCTION SERVER
120
  if __name__ == "__main__":
121
  print("βœ… Starting Flask API Server on port 7860...")