Rammohan0504 commited on
Commit
23efa98
Β·
verified Β·
1 Parent(s): 3f35adb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -3
app.py CHANGED
@@ -1,3 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  with gr.Blocks() as demo:
2
  gr.HTML("<h1 style='text-align: center;'>πŸ› Biryani Hub Menu πŸ›</h1>")
3
 
@@ -45,12 +91,12 @@ with gr.Blocks() as demo:
45
 
46
  selected_dish_name = gr.Textbox(visible=False)
47
  selected_dish_name.change(
48
- fn=show_dish_details,
49
  inputs=selected_dish_name,
50
- outputs=[popup, dish_image, dish_name, dish_description, spice_dropdown, portion_dropdown],
51
  )
52
 
53
- close_popup.click(fn=close_dish_popup, outputs=popup)
54
 
55
  place_order_btn.click(fn=place_order, inputs=[dish_name, spice_dropdown, portion_dropdown], outputs=order_status)
56
 
 
1
+ import gradio as gr
2
+
3
+ # Extended menu data with dish details
4
+ 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"]
20
+ portion_options = ["πŸ§† Small", "🍽 Medium", "πŸ› Large"]
21
+
22
+ def display_dishes(category):
23
+ filtered_dishes = [dish for dish in menu_data if category == "ALL" or dish["category"] == category]
24
+ html_content = "<div style='display: flex; flex-wrap: wrap; justify-content: center;'>"
25
+ for dish in filtered_dishes:
26
+ html_content += f"""
27
+ <div style='margin: 10px; text-align: center; cursor: pointer; border: 1px solid #ddd;
28
+ padding: 10px; border-radius: 10px; width: 200px; background-color: #f9f9f9;'
29
+ onclick='selectDish("{dish['name']}")'>
30
+ <img src='{dish['image']}' alt='{dish['name']}'
31
+ style='width: 180px; height: 120px; object-fit: cover; border-radius: 10px;'>
32
+ <h4 style='margin-top: 10px; font-size: 16px; color: #444;'>{dish['name']}</h4>
33
+ </div>
34
+ """
35
+ html_content += "</div>"
36
+ return html_content
37
+
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."
46
+
47
  with gr.Blocks() as demo:
48
  gr.HTML("<h1 style='text-align: center;'>πŸ› Biryani Hub Menu πŸ›</h1>")
49
 
 
91
 
92
  selected_dish_name = gr.Textbox(visible=False)
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)
100
 
101
  place_order_btn.click(fn=place_order, inputs=[dish_name, spice_dropdown, portion_dropdown], outputs=order_status)
102