geethareddy commited on
Commit
160032f
·
verified ·
1 Parent(s): 155d5c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -11
app.py CHANGED
@@ -13,23 +13,29 @@ def get_food_details(name, image, nutrition):
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()
 
13
  """
14
 
15
  # Gradio Interface
16
+ with gr.Blocks(css="templates/style.css") 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
  with gr.Row():
23
+ for idx, item in enumerate(items):
24
+ # Each block must have a unique variable or unique creation
25
+ with gr.Column():
26
+ btn = gr.Button(f"{item['name']}", elem_id=f"menu-item-{idx}")
27
+ output = gr.HTML()
28
+
29
+ btn.click(
30
+ fn=get_food_details,
31
+ inputs=[
32
+ gr.Text(item['name']),
33
+ gr.Text(item['image']),
34
+ gr.Text(item['nutrition'])
35
+ ],
36
+ outputs=output
37
+ )
38
+
39
  gr.Markdown("<p style='text-align:center; margin-top:20px;'>© 2024 Delicious Restaurant | Built with ❤️</p>")
40
 
41
  demo.launch()