Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
# Menu data dictionary with
|
| 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"},
|
|
@@ -19,13 +19,13 @@ menu_items = {
|
|
| 19 |
}
|
| 20 |
}
|
| 21 |
|
| 22 |
-
# Function to
|
| 23 |
def display_card(item_name, section):
|
| 24 |
item = menu_items[section][item_name]
|
| 25 |
-
image_path = item
|
| 26 |
-
nutrition = item
|
| 27 |
-
portion = item
|
| 28 |
-
price = item
|
| 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;'>
|
|
@@ -48,15 +48,19 @@ def display_card(item_name, section):
|
|
| 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 |
-
|
| 61 |
-
|
|
|
|
|
|
|
| 62 |
app.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
# Menu data dictionary with images, 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"},
|
|
|
|
| 19 |
}
|
| 20 |
}
|
| 21 |
|
| 22 |
+
# Function to generate the popup card
|
| 23 |
def display_card(item_name, section):
|
| 24 |
item = menu_items[section][item_name]
|
| 25 |
+
image_path = item["image"]
|
| 26 |
+
nutrition = item["nutrition"]
|
| 27 |
+
portion = item["portion"]
|
| 28 |
+
price = item["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;'>
|
|
|
|
| 48 |
# Gradio App
|
| 49 |
with gr.Blocks() as app:
|
| 50 |
gr.Markdown("# 🍽️ Indian & Chinese Restaurant Menu")
|
| 51 |
+
|
| 52 |
+
# Single popup card output
|
| 53 |
+
card_output = gr.HTML()
|
| 54 |
+
|
| 55 |
# Display each section
|
| 56 |
for section, items in menu_items.items():
|
| 57 |
gr.Markdown(f"## {section.upper()}")
|
| 58 |
with gr.Row():
|
| 59 |
for item_name in items.keys():
|
| 60 |
btn = gr.Button(f"{item_name} - {items[item_name]['price']}")
|
|
|
|
| 61 |
btn.click(display_card, inputs=[gr.Text(value=item_name), gr.Text(value=section)], outputs=card_output)
|
| 62 |
+
|
| 63 |
+
# Display the popup card below all buttons
|
| 64 |
+
card_output.render()
|
| 65 |
+
|
| 66 |
app.launch()
|