Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,89 +1,14 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
|
|
|
| 3 |
menu_data = [
|
| 4 |
-
{"name": "
|
| 5 |
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/veg_burger.jpg",
|
| 6 |
-
"description": "
|
| 7 |
-
"price": "$8.99"},
|
| 8 |
-
{"name": "Chicken Biryani", "category": "HALAL",
|
| 9 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/chicken_biryani.jpg",
|
| 10 |
-
"description": "Spicy chicken biryani with aromatic basmati rice and tender chicken pieces.",
|
| 11 |
-
"price": "$12.99"},
|
| 12 |
-
{"name": "Paneer Butter Masala", "category": "VEGAN",
|
| 13 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/paneer_butter_masala.jpg",
|
| 14 |
-
"description": "Paneer cooked in a rich and creamy tomato-based gravy.",
|
| 15 |
-
"price": "$10.99"},
|
| 16 |
-
{"name": "Beef Steak", "category": "HALAL",
|
| 17 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/beef_steak.jpg",
|
| 18 |
-
"description": "Juicy beef steak served with mashed potatoes and grilled vegetables.",
|
| 19 |
-
"price": "$15.99"},
|
| 20 |
-
{"name": "Mushroom Soup", "category": "VEGAN",
|
| 21 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/mushroom_soup.jpg",
|
| 22 |
-
"description": "Creamy mushroom soup with fresh herbs.",
|
| 23 |
-
"price": "$7.99"},
|
| 24 |
-
{"name": "Tandoori Chicken", "category": "HALAL",
|
| 25 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/tandoori_chicken.jpg",
|
| 26 |
-
"description": "Grilled chicken marinated in yogurt and spices, cooked in a tandoor.",
|
| 27 |
-
"price": "$11.99"},
|
| 28 |
-
{"name": "Grilled Veggies", "category": "VEGAN",
|
| 29 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/grilled_veggies.jpg",
|
| 30 |
-
"description": "A healthy mix of grilled seasonal vegetables with olive oil.",
|
| 31 |
-
"price": "$9.99"},
|
| 32 |
-
{"name": "Butter Naan", "category": "VEGAN",
|
| 33 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/butter_naan.jpg",
|
| 34 |
-
"description": "Soft and buttery flatbread, perfect to pair with any curry.",
|
| 35 |
-
"price": "$2.99"},
|
| 36 |
-
{"name": "Fish Curry", "category": "HALAL",
|
| 37 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/fish_curry.jpg",
|
| 38 |
-
"description": "Fresh fish cooked in a spicy and tangy curry.",
|
| 39 |
"price": "$13.99"},
|
| 40 |
-
{"name": "Vegetable Salad", "category": "VEGAN",
|
| 41 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/vegetable_salad.jpg",
|
| 42 |
-
"description": "A mix of fresh greens, tomatoes, cucumbers, and a light dressing.",
|
| 43 |
-
"price": "$6.99"},
|
| 44 |
-
{"name": "Veg Spring Rolls", "category": "VEGAN",
|
| 45 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/veg_spring_rolls.jpg",
|
| 46 |
-
"description": "Crispy spring rolls filled with fresh vegetables.",
|
| 47 |
-
"price": "$5.99"},
|
| 48 |
-
{"name": "Chicken Kebab", "category": "HALAL",
|
| 49 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/chicken_kebab.jpg",
|
| 50 |
-
"description": "Juicy chicken kebabs grilled to perfection with a mix of spices.",
|
| 51 |
-
"price": "$9.99"},
|
| 52 |
-
{"name": "Dal Makhani", "category": "VEGAN",
|
| 53 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/dal_makhani.jpg",
|
| 54 |
-
"description": "Rich and creamy black lentils slow-cooked with spices.",
|
| 55 |
-
"price": "$8.99"},
|
| 56 |
-
{"name": "Lamb Curry", "category": "HALAL",
|
| 57 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/lamb_curry.jpg",
|
| 58 |
-
"description": "Tender lamb pieces cooked in a flavorful curry sauce.",
|
| 59 |
-
"price": "$14.99"},
|
| 60 |
-
{"name": "Mixed Veg Curry", "category": "VEGAN",
|
| 61 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/mixed_veg_curry.jpg",
|
| 62 |
-
"description": "A medley of fresh vegetables cooked in a lightly spiced curry.",
|
| 63 |
-
"price": "$9.99"},
|
| 64 |
-
{"name": "Chicken Wings", "category": "HALAL",
|
| 65 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/chicken_wings.jpg",
|
| 66 |
-
"description": "Crispy chicken wings tossed in a tangy sauce.",
|
| 67 |
-
"price": "$12.99"},
|
| 68 |
-
{"name": "Aloo Paratha", "category": "VEGAN",
|
| 69 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/aloo_paratha.jpg",
|
| 70 |
-
"description": "Indian flatbread stuffed with spiced mashed potatoes.",
|
| 71 |
-
"price": "$3.99"},
|
| 72 |
-
{"name": "Egg Curry", "category": "HALAL",
|
| 73 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/egg_curry.jpg",
|
| 74 |
-
"description": "Boiled eggs cooked in a spiced tomato gravy.",
|
| 75 |
-
"price": "$9.99"},
|
| 76 |
-
{"name": "Chickpea Salad", "category": "VEGAN",
|
| 77 |
-
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/chickpea_salad.jpg",
|
| 78 |
-
"description": "A refreshing salad made with chickpeas, fresh vegetables, and herbs.",
|
| 79 |
-
"price": "$7.99"}
|
| 80 |
]
|
| 81 |
|
| 82 |
-
|
| 83 |
-
# The rest of the code remains unchanged
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
spice_levels = ["American Mild", "American Medium", "American Spicy",
|
| 88 |
"Indian Mild", "Indian Medium", "Indian Spicy", "Indian Very Spicy"]
|
| 89 |
extras = [
|
|
@@ -142,46 +67,53 @@ with gr.Blocks() as demo:
|
|
| 142 |
dish_display = gr.HTML(value=display_dishes("ALL"))
|
| 143 |
|
| 144 |
# JavaScript for managing the pop-up
|
| 145 |
-
gr.HTML("""
|
| 146 |
-
<div id="popup" style="display: none; position: fixed;
|
| 147 |
-
|
| 148 |
-
|
| 149 |
<img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 10px;">
|
| 150 |
<h2 id="popup-title" style="margin-top: 20px; color: #444;"></h2>
|
| 151 |
<p id="popup-description" style="margin-top: 10px; font-size: 16px; color: #666;"></p>
|
| 152 |
<p id="popup-price" style="margin-top: 10px; font-size: 16px; color: #444;"></p>
|
| 153 |
|
| 154 |
-
<
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
<script>
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
popupDescription.textContent = description;
|
| 171 |
-
popupPrice.textContent = "Price: " + price;
|
| 172 |
-
|
| 173 |
-
// Position popup near the clicked button
|
| 174 |
-
const rect = event.target.getBoundingClientRect();
|
| 175 |
-
popup.style.left = `${rect.left}px`;
|
| 176 |
-
popup.style.top = `${rect.bottom + 10}px`; // Add some space below the button
|
| 177 |
-
|
| 178 |
-
// Display popup
|
| 179 |
-
popup.style.display = 'block';
|
| 180 |
}
|
| 181 |
|
| 182 |
function closePopup() {
|
| 183 |
-
|
| 184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
}
|
| 186 |
</script>
|
| 187 |
""")
|
|
@@ -201,3 +133,6 @@ with gr.Blocks() as demo:
|
|
| 201 |
)
|
| 202 |
|
| 203 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
# Menu data
|
| 4 |
menu_data = [
|
| 5 |
+
{"name": "Vegetable Biryani", "category": "VEGAN",
|
| 6 |
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/veg_burger.jpg",
|
| 7 |
+
"description": "An Indian dish made to be thoroughly enjoyed by anyone who eats it. Made with the best basmati rice and a perfect blend of spices, cooked in original dum style.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
"price": "$13.99"},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
]
|
| 10 |
|
| 11 |
+
# Spice levels and extras
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
spice_levels = ["American Mild", "American Medium", "American Spicy",
|
| 13 |
"Indian Mild", "Indian Medium", "Indian Spicy", "Indian Very Spicy"]
|
| 14 |
extras = [
|
|
|
|
| 67 |
dish_display = gr.HTML(value=display_dishes("ALL"))
|
| 68 |
|
| 69 |
# JavaScript for managing the pop-up
|
| 70 |
+
gr.HTML(f"""
|
| 71 |
+
<div id="popup" style="display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
|
| 72 |
+
background-color: white; padding: 20px; border-radius: 10px;
|
| 73 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;">
|
| 74 |
<img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 10px;">
|
| 75 |
<h2 id="popup-title" style="margin-top: 20px; color: #444;"></h2>
|
| 76 |
<p id="popup-description" style="margin-top: 10px; font-size: 16px; color: #666;"></p>
|
| 77 |
<p id="popup-price" style="margin-top: 10px; font-size: 16px; color: #444;"></p>
|
| 78 |
|
| 79 |
+
<h4 style="text-align: left; margin-top: 20px;">Choose a spice level</h4>
|
| 80 |
+
<div id="spice-levels-container" style="display: flex; flex-wrap: wrap; justify-content: space-between; border: 1px solid #ddd; padding: 10px; border-radius: 5px;">
|
| 81 |
+
""" + "".join([f'<label style="margin-right: 10px; display: block;"><input type="radio" name="spice" value="{spice}" style="margin-right: 5px;">{spice}</label>' for spice in spice_levels]) + """
|
| 82 |
+
</div>
|
| 83 |
+
|
| 84 |
+
<h4 style="text-align: left; margin-top: 20px;">Choose Extras</h4>
|
| 85 |
+
<div id="extras-container" style="display: flex; flex-wrap: wrap; justify-content: space-between; border: 1px solid #ddd; padding: 10px; border-radius: 5px;">
|
| 86 |
+
""" + "".join([f'<label style="margin-right: 10px; display: block;"><input type="checkbox" name="extras" value="{extra["name"]}" style="margin-right: 5px;">{extra["name"]} + {extra["price"]}</label>' for extra in extras]) + """
|
| 87 |
+
</div>
|
| 88 |
|
| 89 |
+
<button onclick="addToCart()"
|
| 90 |
+
style="margin-top: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none;
|
| 91 |
+
border-radius: 5px; cursor: pointer;">Add to Cart</button>
|
| 92 |
+
<button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #28a745;
|
| 93 |
+
color: white; border: none; border-radius: 5px; cursor: pointer;">Close</button>
|
| 94 |
+
</div>
|
| 95 |
<script>
|
| 96 |
+
let selectedSpice = null;
|
| 97 |
+
let selectedExtras = [];
|
| 98 |
+
|
| 99 |
+
function showPopup(image, title, description, price) {
|
| 100 |
+
document.getElementById('popup-image').src = image;
|
| 101 |
+
document.getElementById('popup-title').textContent = title;
|
| 102 |
+
document.getElementById('popup-description').textContent = description;
|
| 103 |
+
document.getElementById('popup-price').textContent = "Price: " + price;
|
| 104 |
+
|
| 105 |
+
document.getElementById('popup').style.display = 'block';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
}
|
| 107 |
|
| 108 |
function closePopup() {
|
| 109 |
+
document.getElementById('popup').style.display = 'none';
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
function addToCart() {
|
| 113 |
+
const spice = document.querySelector('input[name=spice]:checked')?.value || "No spice selected";
|
| 114 |
+
const extras = Array.from(document.querySelectorAll('input[name=extras]:checked')).map(input => input.value);
|
| 115 |
+
alert(Added with spice level: ${spice}, and extras: ${extras.join(", ")});
|
| 116 |
+
closePopup();
|
| 117 |
}
|
| 118 |
</script>
|
| 119 |
""")
|
|
|
|
| 133 |
)
|
| 134 |
|
| 135 |
demo.launch()
|
| 136 |
+
|
| 137 |
+
ChatGPT said:
|
| 138 |
+
ChatGPT
|