Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from flask import Flask, request, jsonify, render_template
|
| 3 |
+
|
| 4 |
+
app = Flask(__name__)
|
| 5 |
+
|
| 6 |
+
# A simple route to display the menu page (index.html)
|
| 7 |
+
@app.route("/")
|
| 8 |
+
def index():
|
| 9 |
+
return render_template("index.html") # Make sure this is the correct path to your HTML file
|
| 10 |
+
|
| 11 |
+
# Order endpoint - to handle order submission
|
| 12 |
+
@app.route("/place_order", methods=["POST"])
|
| 13 |
+
def place_order():
|
| 14 |
+
data = request.json
|
| 15 |
+
name = data.get('name')
|
| 16 |
+
email = data.get('email')
|
| 17 |
+
phone = data.get('phone')
|
| 18 |
+
items = data.get('items') # List of items the customer wants to order
|
| 19 |
+
|
| 20 |
+
# For now, just print the order details (In production, save it to a database)
|
| 21 |
+
print(f"Order received! Customer Name: {name}, Email: {email}, Phone: {phone}, Items: {items}")
|
| 22 |
+
|
| 23 |
+
# You can add code here to save the order to your database, if required.
|
| 24 |
+
|
| 25 |
+
# Returning success message
|
| 26 |
+
return jsonify({"message": f"Thank you {name}! Your order has been placed successfully!"}), 200
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
if __name__ == "__main__":
|
| 30 |
+
app.run(debug=True)
|