Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from food_data import FOOD_ITEMS
|
3 |
+
|
4 |
+
def get_food_details(name, image, nutrition):
|
5 |
+
"""Returns the popup card details."""
|
6 |
+
return f"""
|
7 |
+
<div style='text-align: center;'>
|
8 |
+
<img src='{image}' alt='{name}' style='width: 100%; border-radius: 10px;'>
|
9 |
+
<h3>{name}</h3>
|
10 |
+
<p>{nutrition}</p>
|
11 |
+
<p style='color: gray;'>Portion Size: Standard</p>
|
12 |
+
</div>
|
13 |
+
"""
|
14 |
+
|
15 |
+
# Gradio Interface
|
16 |
+
with gr.Blocks(theme="soft") as demo:
|
17 |
+
gr.Markdown("<h1 style='text-align:center;'>🍽️ Restaurant Menu 🍽️</h1>")
|
18 |
+
gr.Markdown("<p style='text-align:center;'>Explore our Vegetarian and Non-Vegetarian Dishes</p>")
|
19 |
+
|
20 |
+
for category, items in FOOD_ITEMS.items():
|
21 |
+
gr.Markdown(f"<h2 style='color:#FF6347;'>{category} Menu</h2>")
|
22 |
+
|
23 |
+
with gr.Row():
|
24 |
+
for item in items:
|
25 |
+
btn = gr.Button(f"{item['name']}", elem_id="menu-item")
|
26 |
+
popup = gr.HTML("")
|
27 |
+
|
28 |
+
btn.click(fn=get_food_details,
|
29 |
+
inputs=[gr.Text(item['name']), gr.Text(item['image']), gr.Text(item['nutrition'])],
|
30 |
+
outputs=popup)
|
31 |
+
popup.render()
|
32 |
+
|
33 |
+
gr.Markdown("<p style='text-align:center; margin-top:20px;'>© 2024 Delicious Restaurant | Built with ❤️</p>")
|
34 |
+
|
35 |
+
demo.launch()
|