Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,27 +1,62 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from components.menu_display import display_menu
|
| 3 |
-
from components.popup_card import show_popup_card
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
# Menu data dictionary with image, nutrition, and portion size
|
| 4 |
+
menu_items = {
|
| 5 |
+
"Tandoorrr": {
|
| 6 |
+
"Tikka Murgh (Chicken)": {"price": "$16", "image": "static/tikka_murgh.png", "nutrition": "Calories: 220, Protein: 20g, Fat: 10g, Carbs: 5g", "portion": "250g"},
|
| 7 |
+
"Jhinga (Shrimp)": {"price": "$18", "image": "static/jhinga_shrimp.png", "nutrition": "Calories: 180, Protein: 25g, Fat: 8g, Carbs: 3g", "portion": "200g"},
|
| 8 |
+
"Murgh Malai Kabob": {"price": "$17", "image": "static/murgh_malai.png", "nutrition": "Calories: 240, Protein: 22g, Fat: 12g, Carbs: 6g", "portion": "220g"}
|
| 9 |
+
},
|
| 10 |
+
"Dosai": {
|
| 11 |
+
"Plain Dosai": {"price": "$11", "image": "static/plain_dosai.png", "nutrition": "Calories: 150, Protein: 3g, Fat: 5g, Carbs: 25g", "portion": "100g"},
|
| 12 |
+
"Cheese Dosai": {"price": "$12", "image": "static/cheese_dosai.png", "nutrition": "Calories: 250, Protein: 8g, Fat: 12g, Carbs: 30g", "portion": "120g"},
|
| 13 |
+
"Egg Dosai": {"price": "$12", "image": "static/egg_dosai.png", "nutrition": "Calories: 200, Protein: 10g, Fat: 6g, Carbs: 20g", "portion": "130g"},
|
| 14 |
+
"Kheema Dosai (Goat)": {"price": "$15", "image": "static/kheema_dosai.png", "nutrition": "Calories: 280, Protein: 15g, Fat: 15g, Carbs: 20g", "portion": "150g"}
|
| 15 |
+
},
|
| 16 |
+
"Naan (Breads)": {
|
| 17 |
+
"Plain Naan": {"price": "$3", "image": "static/plain_naan.png", "nutrition": "Calories: 150, Protein: 4g, Fat: 2g, Carbs: 30g", "portion": "1 piece"},
|
| 18 |
+
"Garlic Naan": {"price": "$4", "image": "static/garlic_naan.png", "nutrition": "Calories: 170, Protein: 5g, Fat: 4g, Carbs: 35g", "portion": "1 piece"}
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
|
| 22 |
+
# Function to display popup card with image, nutrition, and portion
|
| 23 |
+
def display_card(item_name, section):
|
| 24 |
+
item = menu_items[section][item_name]
|
| 25 |
+
image_path = item.get("image", "")
|
| 26 |
+
nutrition = item.get("nutrition", "No data available")
|
| 27 |
+
portion = item.get("portion", "Not specified")
|
| 28 |
+
price = item.get("price", "")
|
| 29 |
+
|
| 30 |
+
card = f"""
|
| 31 |
+
<div style='font-family: Arial, sans-serif; border: 1px solid #ddd; border-radius: 10px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); max-width: 400px; margin: auto; position: relative; background-color: white;'>
|
| 32 |
+
<!-- Close Button -->
|
| 33 |
+
<div style='position: absolute; top: 10px; right: 10px;'>
|
| 34 |
+
<button onclick="document.getElementById('popup-card').style.display='none'" style='background: none; border: none; font-size: 18px; cursor: pointer;'>✖</button>
|
| 35 |
+
</div>
|
| 36 |
+
<!-- Image -->
|
| 37 |
+
<img src='{image_path}' alt='{item_name}' style='width: 100%; border-top-left-radius: 10px; border-top-right-radius: 10px;'>
|
| 38 |
+
<!-- Nutrition and Portion -->
|
| 39 |
+
<div style='padding: 15px; text-align: left;'>
|
| 40 |
+
<h3 style='margin: 0; color: #444;'>{item_name} - {price}</h3>
|
| 41 |
+
<p style='margin: 10px 0; color: #666;'>Nutrition: {nutrition}</p>
|
| 42 |
+
<p style='margin: 10px 0; color: #666;'>Portion Size: {portion}</p>
|
| 43 |
+
</div>
|
| 44 |
+
</div>
|
| 45 |
+
"""
|
| 46 |
+
return card
|
| 47 |
|
| 48 |
+
# Gradio App
|
| 49 |
+
with gr.Blocks() as app:
|
| 50 |
+
gr.Markdown("# 🍽️ Indian & Chinese Restaurant Menu")
|
| 51 |
+
|
| 52 |
+
# Display each section
|
| 53 |
+
for section, items in menu_items.items():
|
| 54 |
+
gr.Markdown(f"## {section.upper()}")
|
| 55 |
+
with gr.Row():
|
| 56 |
+
for item_name in items.keys():
|
| 57 |
+
btn = gr.Button(f"{item_name} - {items[item_name]['price']}")
|
| 58 |
+
card_output = gr.HTML() # Popup card output
|
| 59 |
+
btn.click(display_card, inputs=[gr.Text(value=item_name), gr.Text(value=section)], outputs=card_output)
|
| 60 |
+
card_output.render()
|
| 61 |
+
|
| 62 |
+
app.launch()
|