Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,30 +1,16 @@
|
|
| 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")
|
| 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)
|
|
|
|
|
|
|
| 1 |
from flask import Flask, request, jsonify, render_template
|
| 2 |
+
from werkzeug.urls import url_parse, url_join # Correct way to import
|
| 3 |
|
| 4 |
app = Flask(__name__)
|
| 5 |
|
|
|
|
| 6 |
@app.route("/")
|
| 7 |
def index():
|
| 8 |
+
return render_template("index.html")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
@app.route("/submit", methods=["POST"])
|
| 11 |
+
def submit():
|
| 12 |
+
data = request.get_json()
|
| 13 |
+
return jsonify({"message": "Data received", "data": data}), 200
|
| 14 |
|
| 15 |
if __name__ == "__main__":
|
| 16 |
app.run(debug=True)
|