Spaces:
Sleeping
Sleeping
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Dynamic Menu</title> | |
| <link rel="stylesheet" href="/static/styles.css"> | |
| <script> | |
| // Function to handle pop-up | |
| function openPopup(dishName) { | |
| fetch("/menu_item", { | |
| method: "POST", | |
| headers: { "Content-Type": "application/json" }, | |
| body: JSON.stringify({ dish_name: dishName }), | |
| }) | |
| .then(response => response.json()) | |
| .then(data => { | |
| if (data.error) { | |
| alert(data.error); | |
| } else { | |
| const popup = document.getElementById("popup"); | |
| popup.innerHTML = ` | |
| <h2>${data["Dish Name"]}</h2> | |
| <img src="${data["Image URL"]}" alt="${data["Dish Name"]}"> | |
| <p><strong>Description:</strong> ${data["Description"]}</p> | |
| <p><strong>Ingredients:</strong> ${data["Ingredients"]}</p> | |
| <p><strong>Allergen Info:</strong> ${data["Allergen Info"]}</p> | |
| <p><strong>Recommended Items:</strong> ${data["Recommended Items"]}</p> | |
| <p><strong>Spice Levels:</strong> ${data["Spice Levels"]}</p> | |
| <button onclick="closePopup()">Close</button> | |
| `; | |
| popup.style.display = "block"; | |
| } | |
| }); | |
| } | |
| // Function to close the pop-up | |
| function closePopup() { | |
| document.getElementById("popup").style.display = "none"; | |
| } | |
| </script> | |
| </head> | |
| <body> | |
| <h1>Dynamic Menu</h1> | |
| <div id="menu-container"> | |
| {% for category, items in menu.items() %} | |
| <div class="menu-category"> | |
| <h2>{{ category }}</h2> | |
| <div class="menu-items"> | |
| {% for item in items %} | |
| <div class="menu-item"> | |
| <img src="{{ item['Image URL'] }}" alt="{{ item['Dish Name'] }}"> | |
| <h3>{{ item['Dish Name'] }}</h3> | |
| <p>${{ item['Price'] }}</p> | |
| <button onclick="openPopup('{{ item['Dish Name'] }}')">Add</button> | |
| </div> | |
| {% endfor %} | |
| </div> | |
| </div> | |
| {% endfor %} | |
| </div> | |
| <!-- Pop-Up Modal --> | |
| <div id="popup" class="popup"></div> | |
| </body> | |
| </html> | |