Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -85,8 +85,7 @@ def dashboard():
|
|
| 85 |
|
| 86 |
@app.route('/login', methods=['POST'])
|
| 87 |
def login():
|
| 88 |
-
|
| 89 |
-
data = request.json # Assuming voice bot sends JSON data
|
| 90 |
name = data.get('name')
|
| 91 |
email = data.get('email')
|
| 92 |
phone_number = data.get('phone_number')
|
|
@@ -96,43 +95,13 @@ def login():
|
|
| 96 |
|
| 97 |
try:
|
| 98 |
customer_login = create_salesforce_record(sf, name, email, phone_number)
|
| 99 |
-
return
|
| 100 |
except Exception as e:
|
| 101 |
return jsonify({'error': f'Failed to create record in Salesforce: {str(e)}'}), 500
|
| 102 |
|
| 103 |
-
@app.route("/submit", methods=["POST"])
|
| 104 |
-
def submit():
|
| 105 |
-
data = request.json
|
| 106 |
-
name = data.get('name')
|
| 107 |
-
email = data.get('email')
|
| 108 |
-
phone = data.get('phone')
|
| 109 |
-
|
| 110 |
-
if not name or not email or not phone:
|
| 111 |
-
return jsonify({'error': 'Missing data'}), 400
|
| 112 |
-
|
| 113 |
-
try:
|
| 114 |
-
# Create Salesforce record
|
| 115 |
-
customer_login = sf.Customer_Login__c.create({
|
| 116 |
-
'Name': name,
|
| 117 |
-
'Email__c': email,
|
| 118 |
-
'Phone_Number__c': phone
|
| 119 |
-
})
|
| 120 |
-
|
| 121 |
-
if customer_login.get('id'):
|
| 122 |
-
print(f"Success: Customer record created with ID: {customer_login['id']}")
|
| 123 |
-
return jsonify({'success': True})
|
| 124 |
-
else:
|
| 125 |
-
print("Failed: No ID returned after creating the record.")
|
| 126 |
-
return jsonify({'error': 'Failed to create record'}), 500
|
| 127 |
-
|
| 128 |
-
except Exception as e:
|
| 129 |
-
print(f"Error: {str(e)}") # Print error message if an exception occurs
|
| 130 |
-
return jsonify({'error': str(e)}), 500
|
| 131 |
-
|
| 132 |
-
|
| 133 |
@app.route("/menu", methods=["GET"])
|
| 134 |
def menu_page():
|
| 135 |
-
menu_items = get_menu_items(sf)
|
| 136 |
menu_data = [{"name": item['Name'], "price": item['Price__c'], "ingredients": item['Ingredients__c'], "category": item['Category__c']} for item in menu_items]
|
| 137 |
return render_template("menu_page.html", menu_items=menu_data)
|
| 138 |
|
|
@@ -230,4 +199,4 @@ def transcribe():
|
|
| 230 |
|
| 231 |
# Start Production Server
|
| 232 |
if __name__ == "__main__":
|
| 233 |
-
serve(app, host="0.0.0.0", port=7860)
|
|
|
|
| 85 |
|
| 86 |
@app.route('/login', methods=['POST'])
|
| 87 |
def login():
|
| 88 |
+
data = request.json
|
|
|
|
| 89 |
name = data.get('name')
|
| 90 |
email = data.get('email')
|
| 91 |
phone_number = data.get('phone_number')
|
|
|
|
| 95 |
|
| 96 |
try:
|
| 97 |
customer_login = create_salesforce_record(sf, name, email, phone_number)
|
| 98 |
+
return jsonify({'success': True, 'message': 'Successfully logged in'}), 200
|
| 99 |
except Exception as e:
|
| 100 |
return jsonify({'error': f'Failed to create record in Salesforce: {str(e)}'}), 500
|
| 101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
@app.route("/menu", methods=["GET"])
|
| 103 |
def menu_page():
|
| 104 |
+
menu_items = get_menu_items(sf)
|
| 105 |
menu_data = [{"name": item['Name'], "price": item['Price__c'], "ingredients": item['Ingredients__c'], "category": item['Category__c']} for item in menu_items]
|
| 106 |
return render_template("menu_page.html", menu_items=menu_data)
|
| 107 |
|
|
|
|
| 199 |
|
| 200 |
# Start Production Server
|
| 201 |
if __name__ == "__main__":
|
| 202 |
+
serve(app, host="0.0.0.0", port=7860)
|