geethareddy commited on
Commit
185e476
·
verified ·
1 Parent(s): 7a1e1d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import gradio as gr
2
 
3
- # Menu data dictionary with image, 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,13 +19,13 @@ menu_items = {
19
  }
20
  }
21
 
22
- # Function to display popup card with image, nutrition, and portion
23
  def display_card(item_name, section):
24
  item = menu_items[section][item_name]
25
- image_path = item.get("image", "")
26
- nutrition = item.get("nutrition", "No data available")
27
- portion = item.get("portion", "Not specified")
28
- price = item.get("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,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
- card_output.render()
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()