Spaces:
Sleeping
Sleeping
Create menu_page.html
Browse files- templates/menu_page.html +40 -0
templates/menu_page.html
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Menu</title>
|
| 7 |
+
</head>
|
| 8 |
+
<body>
|
| 9 |
+
<h1>Welcome to the Menu</h1>
|
| 10 |
+
<div id="menu">
|
| 11 |
+
{% for item in menu_items %}
|
| 12 |
+
<div class="menu-item">
|
| 13 |
+
<h2>{{ item.name }}</h2>
|
| 14 |
+
<p>Price: ${{ item.price }}</p>
|
| 15 |
+
<p>Ingredients: {{ item.ingredients }}</p>
|
| 16 |
+
<p>Category: {{ item.category }}</p>
|
| 17 |
+
<button onclick="orderItem('{{ item.name }}')">Order</button>
|
| 18 |
+
</div>
|
| 19 |
+
{% endfor %}
|
| 20 |
+
</div>
|
| 21 |
+
|
| 22 |
+
<script>
|
| 23 |
+
function orderItem(itemName) {
|
| 24 |
+
let quantity = prompt("How many would you like to order?");
|
| 25 |
+
fetch("/order", {
|
| 26 |
+
method: "POST",
|
| 27 |
+
headers: {
|
| 28 |
+
"Content-Type": "application/json"
|
| 29 |
+
},
|
| 30 |
+
body: JSON.stringify({ "item_name": itemName, "quantity": quantity })
|
| 31 |
+
})
|
| 32 |
+
.then(response => response.json())
|
| 33 |
+
.then(data => {
|
| 34 |
+
alert(data.message);
|
| 35 |
+
})
|
| 36 |
+
.catch(error => console.error("Error placing order:", error));
|
| 37 |
+
}
|
| 38 |
+
</script>
|
| 39 |
+
</body>
|
| 40 |
+
</html>
|