Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,50 +1,99 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
|
| 5 |
-
"
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
}
|
| 15 |
|
| 16 |
-
# Function to display popup
|
| 17 |
-
def display_card(item_name):
|
| 18 |
-
|
| 19 |
-
return
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
with gr.Blocks(
|
| 27 |
-
gr.Markdown("
|
| 28 |
|
| 29 |
-
|
| 30 |
-
gr.Markdown("<h2>TANDOORRR</h2>")
|
| 31 |
-
with gr.Row():
|
| 32 |
-
for item in ["Tikka Murgh (Chicken)", "Jhinga (Shrimp)", "Murgh Malai Kabob"]:
|
| 33 |
-
btn = gr.Button(f"{item} - {menu_data[item]['price']}")
|
| 34 |
-
btn.click(display_card, inputs=[gr.Text(item, visible=False)], outputs=gr.Markdown())
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
for
|
| 40 |
-
|
| 41 |
-
|
|
|
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
with gr.Row():
|
| 46 |
-
for item in ["Plain Naan", "Garlic Naan"]:
|
| 47 |
-
btn = gr.Button(f"{item} - {menu_data[item]['price']}")
|
| 48 |
-
btn.click(display_card, inputs=[gr.Text(item, visible=False)], outputs=gr.Markdown())
|
| 49 |
|
| 50 |
-
|
|
|
|
| 1 |
+
import os
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
# Menu data with absolute paths for images
|
| 5 |
+
menu_items = {
|
| 6 |
+
"Tandoorrr": {
|
| 7 |
+
"Tikka Murgh (Chicken)": {
|
| 8 |
+
"price": "$16",
|
| 9 |
+
"image": os.path.abspath("static/tikka_murgh.png"),
|
| 10 |
+
"nutrition": "Calories: 220, Protein: 20g, Fat: 10g, Carbs: 5g",
|
| 11 |
+
"portion": "250g"
|
| 12 |
+
},
|
| 13 |
+
"Jhinga (Shrimp)": {
|
| 14 |
+
"price": "$18",
|
| 15 |
+
"image": os.path.abspath("static/jhinga_shrimp.png"),
|
| 16 |
+
"nutrition": "Calories: 180, Protein: 25g, Fat: 8g, Carbs: 3g",
|
| 17 |
+
"portion": "200g"
|
| 18 |
+
},
|
| 19 |
+
"Murgh Malai Kabob": {
|
| 20 |
+
"price": "$17",
|
| 21 |
+
"image": os.path.abspath("static/murgh_malai.png"),
|
| 22 |
+
"nutrition": "Calories: 240, Protein: 22g, Fat: 12g, Carbs: 6g",
|
| 23 |
+
"portion": "220g"
|
| 24 |
+
},
|
| 25 |
+
},
|
| 26 |
+
"Dosai": {
|
| 27 |
+
"Plain Dosai": {
|
| 28 |
+
"price": "$11",
|
| 29 |
+
"image": os.path.abspath("static/plain_dosai.png"),
|
| 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 popup with image and details
|
| 69 |
+
def display_card(item_name, section):
|
| 70 |
+
item = menu_items[section][item_name]
|
| 71 |
+
return f"""
|
| 72 |
+
<div style='font-family: Arial, sans-serif; max-width: 400px; border: 1px solid #ddd; border-radius: 10px; box-shadow: 0 5px 15px rgba(0,0,0,0.2);'>
|
| 73 |
+
<img src='file://{item["image"]}' style='width: 100%; border-top-left-radius: 10px; border-top-right-radius: 10px;' alt='{item_name}' />
|
| 74 |
+
<div style='padding: 10px; text-align: left;'>
|
| 75 |
+
<h3 style='margin: 0; color: #444;'>{item_name} - {item["price"]}</h3>
|
| 76 |
+
<p style='margin: 5px 0; color: #666;'>Nutrition: {item["nutrition"]}</p>
|
| 77 |
+
<p style='margin: 5px 0; color: #666;'>Portion Size: {item["portion"]}</p>
|
| 78 |
+
</div>
|
| 79 |
+
</div>
|
| 80 |
+
"""
|
| 81 |
|
| 82 |
+
# Gradio App
|
| 83 |
+
with gr.Blocks() as app:
|
| 84 |
+
gr.Markdown("# 🍽️ Indian & Chinese Restaurant Menu")
|
| 85 |
|
| 86 |
+
card_output = gr.HTML()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
+
# Display buttons row-wise
|
| 89 |
+
for section, items in menu_items.items():
|
| 90 |
+
gr.Markdown(f"## {section.upper()}")
|
| 91 |
+
for item_name, details in items.items():
|
| 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()
|