lokesh341 commited on
Commit
3480da8
Β·
verified Β·
1 Parent(s): 9d5c08a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -10
app.py CHANGED
@@ -13,17 +13,21 @@ from simple_salesforce import Salesforce
13
  import requests
14
 
15
  # Initialize Flask app
16
- app = Flask(__name__)
17
  app.secret_key = os.urandom(24)
18
 
19
- # βœ… Print Available Routes at Startup
20
- @app.before_request
21
- def print_routes():
22
- if not hasattr(app, 'printed_routes'):
23
- app.printed_routes = True
24
- print("\nβœ… Available Routes:")
25
- for rule in app.url_map.iter_rules():
26
- print(f"➑ {rule}")
 
 
 
 
27
 
28
  # βœ… ROUTE: List All Routes for Debugging
29
  @app.route("/routes", methods=["GET"])
@@ -36,7 +40,12 @@ def list_routes():
36
  # βœ… HOME ROUTE
37
  @app.route("/", methods=["GET"])
38
  def home():
39
- return jsonify({"message": "Welcome to Biryani Hub API. Use /register, /login, /menu, or /routes to check available endpoints."})
 
 
 
 
 
40
 
41
  # βœ… REGISTER API
42
  @app.route("/register", methods=["POST"])
 
13
  import requests
14
 
15
  # Initialize Flask app
16
+ app = Flask(__name__, template_folder="templates")
17
  app.secret_key = os.urandom(24)
18
 
19
+ # βœ… Enable Debug Mode
20
+ app.config["DEBUG"] = True
21
+
22
+ # βœ… Salesforce Connection Setup
23
+ try:
24
+ print("Attempting to connect to Salesforce...")
25
+ sf = Salesforce(username='[email protected]',
26
+ password='Sati@1020',
27
+ security_token='sSSjyhInIsUohKpG8sHzty2q')
28
+ print("βœ… Connected to Salesforce successfully!")
29
+ except Exception as e:
30
+ print(f"❌ Failed to connect to Salesforce: {str(e)}")
31
 
32
  # βœ… ROUTE: List All Routes for Debugging
33
  @app.route("/routes", methods=["GET"])
 
40
  # βœ… HOME ROUTE
41
  @app.route("/", methods=["GET"])
42
  def home():
43
+ return jsonify({"message": "Welcome to Biryani Hub API. Use /register, /login, /menu, /index, or /routes to check available endpoints."})
44
+
45
+ # βœ… RENDER INDEX.HTML FOR REGISTER & LOGIN
46
+ @app.route("/index", methods=["GET"])
47
+ def index_page():
48
+ return render_template("index.html")
49
 
50
  # βœ… REGISTER API
51
  @app.route("/register", methods=["POST"])