Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -134,6 +134,22 @@ def add_to_cart():
|
|
134 |
|
135 |
return jsonify({"success": True, "message": f"Added {item_name} to cart."})
|
136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
# Start Production Server
|
138 |
if __name__ == "__main__":
|
139 |
serve(app, host="0.0.0.0", port=7860)
|
|
|
134 |
|
135 |
return jsonify({"success": True, "message": f"Added {item_name} to cart."})
|
136 |
|
137 |
+
@app.route("/register", methods=["POST"])
|
138 |
+
def register():
|
139 |
+
name = request.json.get('name')
|
140 |
+
email = request.json.get('email')
|
141 |
+
phone_number = request.json.get('phone_number')
|
142 |
+
|
143 |
+
if not name or not email or not phone_number:
|
144 |
+
return jsonify({'error': 'Missing required fields'}), 400
|
145 |
+
|
146 |
+
try:
|
147 |
+
customer_login = create_salesforce_record(sf, name, email, phone_number)
|
148 |
+
session['customer_id'] = customer_login['id'] # Store customer ID in session
|
149 |
+
return redirect("/menu") # Redirect to the menu page after successful registration
|
150 |
+
except Exception as e:
|
151 |
+
return jsonify({'error': f'Failed to create record in Salesforce: {str(e)}'}), 500
|
152 |
+
|
153 |
# Start Production Server
|
154 |
if __name__ == "__main__":
|
155 |
serve(app, host="0.0.0.0", port=7860)
|