Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,25 +20,13 @@ menu_data = [
|
|
| 20 |
{"name": "Chicken Manchurian", "category": "HALAL", "image": "https://huggingface.co/spaces/Rammohan0504/First-Project/resolve/main/pictures/Chicken_manchurian.jpg", "description": "A popular Indo-Chinese dish featuring fried chicken pieces tossed in a tangy and spicy sauce.", "price": 13.99},
|
| 21 |
]
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
extras = [
|
| 26 |
-
{"name": "Extra Raitha 4oz", "price": "$1.00"},
|
| 27 |
-
{"name": "Extra Raitha 8oz", "price": "$2.00"},
|
| 28 |
-
{"name": "Extra Salan 4oz", "price": "$1.00"},
|
| 29 |
-
{"name": "Extra Salan 8oz", "price": "$2.00"},
|
| 30 |
-
{"name": "Extra Onion", "price": "$1.00"},
|
| 31 |
-
{"name": "Extra Onion & Lemon", "price": "$2.00"},
|
| 32 |
-
{"name": "Extra Fried Onion 4oz", "price": "$2.00"},
|
| 33 |
-
]
|
| 34 |
|
| 35 |
# Filter dishes by category
|
| 36 |
def filter_dishes(category):
|
| 37 |
if category == "ALL":
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
filtered_menu = [dish for dish in menu_data if dish["category"] == category]
|
| 41 |
-
return generate_dish_html(filtered_menu)
|
| 42 |
|
| 43 |
# Generate dish cards with "Add" button
|
| 44 |
def display_dishes(category):
|
|
@@ -57,7 +45,7 @@ def display_dishes(category):
|
|
| 57 |
<div style='text-align: center;'>
|
| 58 |
<img src='{dish['image']}' alt='{dish['name']}'
|
| 59 |
style='width: 150px; height: 100px; object-fit: cover; border-radius: 10px;'>
|
| 60 |
-
<button onclick="
|
| 61 |
style="margin-top: 15px; padding: 10px 20px; background-color: #28a745; color: white; border: none;
|
| 62 |
border-radius: 5px; cursor: pointer;">Add</button>
|
| 63 |
</div>
|
|
@@ -66,6 +54,7 @@ def display_dishes(category):
|
|
| 66 |
html_content += "</div>"
|
| 67 |
return html_content
|
| 68 |
|
|
|
|
| 69 |
def add_to_cart(item_name, item_price):
|
| 70 |
cart_items.append({"name": item_name, "price": item_price})
|
| 71 |
return f"{item_name} added to cart!"
|
|
|
|
| 20 |
{"name": "Chicken Manchurian", "category": "HALAL", "image": "https://huggingface.co/spaces/Rammohan0504/First-Project/resolve/main/pictures/Chicken_manchurian.jpg", "description": "A popular Indo-Chinese dish featuring fried chicken pieces tossed in a tangy and spicy sauce.", "price": 13.99},
|
| 21 |
]
|
| 22 |
|
| 23 |
+
cart_items = [] # To store items added to the cart
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
# Filter dishes by category
|
| 26 |
def filter_dishes(category):
|
| 27 |
if category == "ALL":
|
| 28 |
+
return menu_data
|
| 29 |
+
return [dish for dish in menu_data if dish["category"] == category]
|
|
|
|
|
|
|
| 30 |
|
| 31 |
# Generate dish cards with "Add" button
|
| 32 |
def display_dishes(category):
|
|
|
|
| 45 |
<div style='text-align: center;'>
|
| 46 |
<img src='{dish['image']}' alt='{dish['name']}'
|
| 47 |
style='width: 150px; height: 100px; object-fit: cover; border-radius: 10px;'>
|
| 48 |
+
<button onclick="addToCart('{dish['name']}', {dish['price']})"
|
| 49 |
style="margin-top: 15px; padding: 10px 20px; background-color: #28a745; color: white; border: none;
|
| 50 |
border-radius: 5px; cursor: pointer;">Add</button>
|
| 51 |
</div>
|
|
|
|
| 54 |
html_content += "</div>"
|
| 55 |
return html_content
|
| 56 |
|
| 57 |
+
# Add item to cart
|
| 58 |
def add_to_cart(item_name, item_price):
|
| 59 |
cart_items.append({"name": item_name, "price": item_price})
|
| 60 |
return f"{item_name} added to cart!"
|