Rammohan0504 commited on
Commit
535be82
Β·
verified Β·
1 Parent(s): 23efa98

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -5,15 +5,15 @@ menu_data = [
5
  {"name": "Veg Burger", "category": "VEGAN",
6
  "image": "https://upload.wikimedia.org/wikipedia/commons/6/6e/Veggie_burger.jpg",
7
  "description": "A delicious vegan burger with plant-based patty, lettuce, and tomato.",
8
- "spice_level": "Medium", "portion_size": "Regular"},
9
  {"name": "Chicken Biryani", "category": "HALAL",
10
  "image": "https://upload.wikimedia.org/wikipedia/commons/7/79/Chicken_Biryani.jpg",
11
  "description": "Spicy chicken biryani with aromatic basmati rice and tender chicken pieces.",
12
- "spice_level": "High", "portion_size": "Large"},
13
  {"name": "Paneer Butter Masala", "category": "VEGAN",
14
  "image": "https://upload.wikimedia.org/wikipedia/commons/3/3d/Paneer_Butter_Masala.jpg",
15
  "description": "Paneer cooked in a rich and creamy tomato-based gravy.",
16
- "spice_level": "Mild", "portion_size": "Medium"},
17
  ]
18
 
19
  spice_options = ["🌢 Mild", "🌢🌢 Medium", "🌢🌢🌢 High"]
@@ -38,8 +38,8 @@ def display_dishes(category):
38
  def get_dish_details(dish_name):
39
  for dish in menu_data:
40
  if dish["name"] == dish_name:
41
- return dish["image"], dish["name"], dish["description"], "🌢 Medium", "🍽 Medium"
42
- return "https://via.placeholder.com/300x200", "Unknown Dish", "No description available.", "N/A", "N/A"
43
 
44
  def place_order(dish_name, spice_level, portion_size):
45
  return f"βœ… Order Confirmed: '{dish_name}' with {spice_level} spice level and {portion_size} portion size."
@@ -75,8 +75,8 @@ with gr.Blocks() as demo:
75
  with gr.Column():
76
  dish_name = gr.Textbox(label="Dish Name", interactive=False)
77
  dish_description = gr.Textbox(label="Description", interactive=False)
78
- spice_dropdown = gr.Radio(label="Select Spice Level", choices=spice_options, value="🌢 Medium")
79
- portion_dropdown = gr.Radio(label="Select Portion Size", choices=portion_options, value="🍽 Medium")
80
  close_popup = gr.Button("Close")
81
 
82
  place_order_btn = gr.Button("Place Order")
@@ -93,7 +93,7 @@ with gr.Blocks() as demo:
93
  selected_dish_name.change(
94
  fn=lambda dish_name: (*get_dish_details(dish_name), gr.update(visible=True)),
95
  inputs=selected_dish_name,
96
- outputs=[dish_image, dish_name, dish_description, popup],
97
  )
98
 
99
  close_popup.click(fn=lambda: gr.update(visible=False), outputs=popup)
 
5
  {"name": "Veg Burger", "category": "VEGAN",
6
  "image": "https://upload.wikimedia.org/wikipedia/commons/6/6e/Veggie_burger.jpg",
7
  "description": "A delicious vegan burger with plant-based patty, lettuce, and tomato.",
8
+ "spice_level": "🌢 Mild", "portion_size": "πŸ§† Small"},
9
  {"name": "Chicken Biryani", "category": "HALAL",
10
  "image": "https://upload.wikimedia.org/wikipedia/commons/7/79/Chicken_Biryani.jpg",
11
  "description": "Spicy chicken biryani with aromatic basmati rice and tender chicken pieces.",
12
+ "spice_level": "🌢🌢 Medium", "portion_size": "πŸ› Large"},
13
  {"name": "Paneer Butter Masala", "category": "VEGAN",
14
  "image": "https://upload.wikimedia.org/wikipedia/commons/3/3d/Paneer_Butter_Masala.jpg",
15
  "description": "Paneer cooked in a rich and creamy tomato-based gravy.",
16
+ "spice_level": "🌢🌢🌢 High", "portion_size": "🍽 Medium"},
17
  ]
18
 
19
  spice_options = ["🌢 Mild", "🌢🌢 Medium", "🌢🌢🌢 High"]
 
38
  def get_dish_details(dish_name):
39
  for dish in menu_data:
40
  if dish["name"] == dish_name:
41
+ return dish["image"], dish["name"], dish["description"], dish["spice_level"], dish["portion_size"]
42
+ return "https://via.placeholder.com/300x200", "Unknown Dish", "No description available.", "🌢 Mild", "πŸ§† Small"
43
 
44
  def place_order(dish_name, spice_level, portion_size):
45
  return f"βœ… Order Confirmed: '{dish_name}' with {spice_level} spice level and {portion_size} portion size."
 
75
  with gr.Column():
76
  dish_name = gr.Textbox(label="Dish Name", interactive=False)
77
  dish_description = gr.Textbox(label="Description", interactive=False)
78
+ spice_dropdown = gr.Radio(label="Select Spice Level", choices=spice_options, value="🌢 Mild")
79
+ portion_dropdown = gr.Radio(label="Select Portion Size", choices=portion_options, value="πŸ§† Small")
80
  close_popup = gr.Button("Close")
81
 
82
  place_order_btn = gr.Button("Place Order")
 
93
  selected_dish_name.change(
94
  fn=lambda dish_name: (*get_dish_details(dish_name), gr.update(visible=True)),
95
  inputs=selected_dish_name,
96
+ outputs=[dish_image, dish_name, dish_description, spice_dropdown, portion_dropdown, popup],
97
  )
98
 
99
  close_popup.click(fn=lambda: gr.update(visible=False), outputs=popup)