Spaces:
Runtime error
Runtime error
Update app.py
#2
by
nagasurendra
- opened
app.py
CHANGED
|
@@ -1,52 +1,46 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
# Menu
|
| 4 |
-
|
| 5 |
-
"
|
| 6 |
-
"
|
| 7 |
-
"
|
| 8 |
-
"
|
|
|
|
| 9 |
},
|
| 10 |
-
"
|
| 11 |
-
"
|
| 12 |
-
"
|
| 13 |
-
"
|
| 14 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
#
|
| 23 |
-
def display_card(item_name
|
| 24 |
-
|
| 25 |
return f"""
|
| 26 |
-
<div style=
|
| 27 |
-
<img src=
|
| 28 |
-
<
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
<p style='margin: 5px 0; color: #666;'>Portion Size: {item["portion"]}</p>
|
| 32 |
-
</div>
|
| 33 |
</div>
|
| 34 |
"""
|
| 35 |
|
| 36 |
-
# Gradio
|
| 37 |
with gr.Blocks() as app:
|
| 38 |
-
gr.Markdown("
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
gr.Markdown(f"## {section.upper()}") # Section title
|
| 45 |
-
for item_name, details in items.items(): # Row per item
|
| 46 |
-
with gr.Row():
|
| 47 |
-
btn = gr.Button(f"{item_name} - {details['price']}")
|
| 48 |
-
btn.click(display_card, inputs=[gr.Textbox(visible=False, value=item_name), gr.Textbox(visible=False, value=section)], outputs=card_output)
|
| 49 |
-
|
| 50 |
-
card_output
|
| 51 |
|
| 52 |
app.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
# Menu Data
|
| 4 |
+
menu_data = {
|
| 5 |
+
"Tikka Murgh (Chicken)": {
|
| 6 |
+
"price": "$16",
|
| 7 |
+
"nutrition": "Calories: 220, Protein: 20g, Fat: 10g, Carbs: 5g",
|
| 8 |
+
"portion": "250g",
|
| 9 |
+
"image": "static/Tikka_Murgh_Chicken.png",
|
| 10 |
},
|
| 11 |
+
"Jhinga (Shrimp)": {
|
| 12 |
+
"price": "$18",
|
| 13 |
+
"nutrition": "Calories: 180, Protein: 25g, Fat: 8g, Carbs: 3g",
|
| 14 |
+
"portion": "200g",
|
| 15 |
+
"image": "static/Jhinga_Shrimp.jpg",
|
| 16 |
+
},
|
| 17 |
+
"Murgh Malai Kabob": {
|
| 18 |
+
"price": "$17",
|
| 19 |
+
"nutrition": "Calories: 240, Protein: 22g, Fat: 12g, Carbs: 7g",
|
| 20 |
+
"portion": "300g",
|
| 21 |
+
"image": "static/Murgh_Malai_Kabob.jpg",
|
| 22 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
}
|
| 24 |
|
| 25 |
+
# Display Card Function
|
| 26 |
+
def display_card(item_name):
|
| 27 |
+
data = menu_data[item_name]
|
| 28 |
return f"""
|
| 29 |
+
<div style="border:1px solid #ccc; padding:10px; border-radius:10px; width:300px; background-color:white;">
|
| 30 |
+
<img src="{data['image']}" style="width:100%; border-radius:10px;" alt="{item_name}">
|
| 31 |
+
<h3>{item_name} - {data['price']}</h3>
|
| 32 |
+
<p>Nutrition: {data['nutrition']}</p>
|
| 33 |
+
<p>Portion Size: {data['portion']}</p>
|
|
|
|
|
|
|
| 34 |
</div>
|
| 35 |
"""
|
| 36 |
|
| 37 |
+
# Gradio Interface
|
| 38 |
with gr.Blocks() as app:
|
| 39 |
+
gr.Markdown("### Indian & Chinese Restaurant Menu")
|
| 40 |
+
with gr.Row():
|
| 41 |
+
for item in menu_data.keys():
|
| 42 |
+
gr.Button(item).click(
|
| 43 |
+
display_card, inputs=[item], outputs=gr.HTML()
|
| 44 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
app.launch()
|