Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,99 +1,58 @@
|
|
| 1 |
-
import os
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
-
"
|
| 7 |
-
"Tikka Murgh (Chicken)":
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
"
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
"
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
"nutrition": "Calories: 150, Protein: 3g, Fat: 5g, Carbs: 25g",
|
| 31 |
-
"portion": "100g"
|
| 32 |
-
},
|
| 33 |
-
"Cheese Dosai": {
|
| 34 |
-
"price": "$12",
|
| 35 |
-
"image": os.path.abspath("static/cheese_dosai.png"),
|
| 36 |
-
"nutrition": "Calories: 250, Protein: 8g, Fat: 12g, Carbs: 30g",
|
| 37 |
-
"portion": "120g"
|
| 38 |
-
},
|
| 39 |
-
"Egg Dosai": {
|
| 40 |
-
"price": "$12",
|
| 41 |
-
"image": os.path.abspath("static/egg_dosai.png"),
|
| 42 |
-
"nutrition": "Calories: 200, Protein: 10g, Fat: 6g, Carbs: 20g",
|
| 43 |
-
"portion": "130g"
|
| 44 |
-
},
|
| 45 |
-
"Kheema Dosai (Goat)": {
|
| 46 |
-
"price": "$15",
|
| 47 |
-
"image": os.path.abspath("static/kheema_dosai.png"),
|
| 48 |
-
"nutrition": "Calories: 280, Protein: 15g, Fat: 15g, Carbs: 20g",
|
| 49 |
-
"portion": "150g"
|
| 50 |
-
},
|
| 51 |
-
},
|
| 52 |
-
"Naan (Breads)": {
|
| 53 |
-
"Plain Naan": {
|
| 54 |
-
"price": "$3",
|
| 55 |
-
"image": os.path.abspath("static/plain_naan.png"),
|
| 56 |
-
"nutrition": "Calories: 150, Protein: 4g, Fat: 2g, Carbs: 30g",
|
| 57 |
-
"portion": "1 piece"
|
| 58 |
-
},
|
| 59 |
-
"Garlic Naan": {
|
| 60 |
-
"price": "$4",
|
| 61 |
-
"image": os.path.abspath("static/garlic_naan.png"),
|
| 62 |
-
"nutrition": "Calories: 170, Protein: 5g, Fat: 4g, Carbs: 35g",
|
| 63 |
-
"portion": "1 piece"
|
| 64 |
-
}
|
| 65 |
-
}
|
| 66 |
}
|
| 67 |
|
| 68 |
-
# Function to display
|
| 69 |
-
def
|
| 70 |
-
item =
|
| 71 |
-
|
| 72 |
-
<div
|
| 73 |
-
<img src=
|
| 74 |
-
<div
|
| 75 |
-
<h3
|
| 76 |
-
<p
|
| 77 |
-
<p
|
| 78 |
</div>
|
|
|
|
| 79 |
</div>
|
| 80 |
"""
|
|
|
|
| 81 |
|
| 82 |
-
# Gradio
|
| 83 |
-
with gr.Blocks() as app:
|
| 84 |
-
gr.Markdown("#
|
| 85 |
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
with gr.Row():
|
| 93 |
-
btn = gr.Button(f"{item_name} - {details['price']}")
|
| 94 |
-
btn.click(display_card, inputs=[gr.Textbox(value=item_name, visible=False), gr.Textbox(value=section, visible=False)], outputs=card_output)
|
| 95 |
-
|
| 96 |
-
# Popup area
|
| 97 |
-
card_output
|
| 98 |
|
| 99 |
app.launch()
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
# Data for menu items
|
| 4 |
+
menu_data = {
|
| 5 |
+
"TANDOORRR": [
|
| 6 |
+
{"name": "Tikka Murgh (Chicken)", "price": "$16", "image": "static/images/tikka_murgh.png",
|
| 7 |
+
"nutrition": "Calories: 220, Protein: 20g, Fat: 10g, Carbs: 5g", "portion": "250g"},
|
| 8 |
+
{"name": "Jhinga (Shrimp)", "price": "$18", "image": "static/images/jhinga_shrimp.png",
|
| 9 |
+
"nutrition": "Calories: 180, Protein: 25g, Fat: 8g, Carbs: 3g", "portion": "200g"},
|
| 10 |
+
{"name": "Murgh Malai Kabab", "price": "$17", "image": "static/images/murgh_malai_kabab.png",
|
| 11 |
+
"nutrition": "Calories: 240, Protein: 22g, Fat: 12g, Carbs: 6g", "portion": "300g"}
|
| 12 |
+
],
|
| 13 |
+
"DOSAI": [
|
| 14 |
+
{"name": "Plain Dosai", "price": "$11", "image": "static/images/plain_dosai.png",
|
| 15 |
+
"nutrition": "Calories: 150, Protein: 3g, Fat: 5g, Carbs: 25g", "portion": "100g"},
|
| 16 |
+
{"name": "Cheese Dosai", "price": "$12", "image": "static/images/cheese_dosai.png",
|
| 17 |
+
"nutrition": "Calories: 200, Protein: 10g, Fat: 8g, Carbs: 22g", "portion": "150g"},
|
| 18 |
+
{"name": "Egg Dosai", "price": "$12", "image": "static/images/egg_dosai.png",
|
| 19 |
+
"nutrition": "Calories: 180, Protein: 12g, Fat: 6g, Carbs: 20g", "portion": "120g"},
|
| 20 |
+
{"name": "Kheema Dosai (Goat)", "price": "$15", "image": "static/images/kheema_dosai.png",
|
| 21 |
+
"nutrition": "Calories: 250, Protein: 20g, Fat: 15g, Carbs: 10g", "portion": "200g"}
|
| 22 |
+
],
|
| 23 |
+
"NAAN (BREADS)": [
|
| 24 |
+
{"name": "Plain Naan", "price": "$3", "image": "static/images/plain_naan.png",
|
| 25 |
+
"nutrition": "Calories: 100, Protein: 2g, Fat: 3g, Carbs: 15g", "portion": "50g"},
|
| 26 |
+
{"name": "Garlic Naan", "price": "$4", "image": "static/images/garlic_naan.png",
|
| 27 |
+
"nutrition": "Calories: 120, Protein: 3g, Fat: 4g, Carbs: 18g", "portion": "60g"}
|
| 28 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
}
|
| 30 |
|
| 31 |
+
# Function to display item details
|
| 32 |
+
def display_item(category, index):
|
| 33 |
+
item = menu_data[category][index]
|
| 34 |
+
card_html = f"""
|
| 35 |
+
<div class="popup-card">
|
| 36 |
+
<img src="{item['image']}" alt="{item['name']}" class="popup-image">
|
| 37 |
+
<div class="popup-details">
|
| 38 |
+
<h3>{item['name']} - {item['price']}</h3>
|
| 39 |
+
<p>Nutrition: {item['nutrition']}</p>
|
| 40 |
+
<p>Portion Size: {item['portion']}</p>
|
| 41 |
</div>
|
| 42 |
+
<button onclick="closePopup()" class="close-button">X</button>
|
| 43 |
</div>
|
| 44 |
"""
|
| 45 |
+
return card_html
|
| 46 |
|
| 47 |
+
# Gradio app
|
| 48 |
+
with gr.Blocks(css="static/css/style.css") as app:
|
| 49 |
+
gr.Markdown("# Indian & Chinese Restaurant Menu")
|
| 50 |
|
| 51 |
+
for category, items in menu_data.items():
|
| 52 |
+
gr.Markdown(f"## {category}")
|
| 53 |
+
for i, item in enumerate(items):
|
| 54 |
+
gr.Button(f"{item['name']} - {item['price']}", elem_id=f"{category}_{i}").click(
|
| 55 |
+
display_item, inputs=[gr.Text(value=category), gr.Text(value=i)], outputs=gr.HTML()
|
| 56 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
app.launch()
|