Rammohan0504 commited on
Commit
a6b58e5
·
verified ·
1 Parent(s): cb3331a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -15
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import gradio as gr
2
 
 
3
  menu_data = [
4
  {"name": "Veg Burger", "category": "VEGAN",
5
  "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/veg_burger.jpg",
@@ -7,26 +8,70 @@ menu_data = [
7
  {"name": "Chicken Biryani", "category": "HALAL",
8
  "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/chicken_biryani.jpg",
9
  "description": "Spicy chicken biryani with aromatic basmati rice and tender chicken pieces."},
10
- # Add more dishes here...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  ]
12
 
13
- # Filter menu based on category
14
- def filter_dishes(category):
15
- if category == "ALL":
16
- return menu_data
17
- return [dish for dish in menu_data if dish["category"] == category]
18
-
19
- # Generate dish cards with JavaScript pop-up
20
  def display_dishes(category):
21
- filtered_dishes = filter_dishes(category)
22
- html_content = "<div style='display: flex; flex-wrap: wrap; gap: 20px; justify-content: center;'>"
23
  for dish in filtered_dishes:
24
  html_content += f"""
25
- <div style='width: 300px; padding: 10px; border: 1px solid #ddd; border-radius: 10px;
26
  background-color: #f9f9f9; text-align: center; cursor: pointer;'
27
  onclick="showPopup('{dish['image']}', '{dish['name']}', '{dish['description']}')">
28
  <img src='{dish['image']}' alt='{dish['name']}'
29
- style='width: 100%; height: 150px; object-fit: cover; border-radius: 10px;'>
30
  <h4 style='margin: 10px 0; color: #444;'>{dish['name']}</h4>
31
  <p style='color: #666; font-size: 14px;'>{dish['description']}</p>
32
  </div>
@@ -38,13 +83,13 @@ def display_dishes(category):
38
  with gr.Blocks() as demo:
39
  gr.HTML("<h1 style='text-align: center; color: #333;'>🍛 Biryani Hub Menu 🍛</h1>")
40
 
41
- # Buttons for category selection
42
  with gr.Row():
43
  btn_all = gr.Button("ALL")
44
  btn_vegan = gr.Button("VEGAN")
45
  btn_halal = gr.Button("HALAL")
46
 
47
- # Dish display section
48
  dish_display = gr.HTML(value=display_dishes("ALL"))
49
 
50
  # Pop-up HTML and JavaScript
@@ -72,7 +117,7 @@ with gr.Blocks() as demo:
72
  </script>
73
  """)
74
 
75
- # Button click events for category filtering
76
  btn_all.click(lambda: gr.update(value=display_dishes("ALL")), outputs=dish_display)
77
  btn_vegan.click(lambda: gr.update(value=display_dishes("VEGAN")), outputs=dish_display)
78
  btn_halal.click(lambda: gr.update(value=display_dishes("HALAL")), outputs=dish_display)
 
1
  import gradio as gr
2
 
3
+ # Menu data
4
  menu_data = [
5
  {"name": "Veg Burger", "category": "VEGAN",
6
  "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/veg_burger.jpg",
 
8
  {"name": "Chicken Biryani", "category": "HALAL",
9
  "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/chicken_biryani.jpg",
10
  "description": "Spicy chicken biryani with aromatic basmati rice and tender chicken pieces."},
11
+ {"name": "Paneer Butter Masala", "category": "VEGAN",
12
+ "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/paneer_butter_masala.jpg",
13
+ "description": "Paneer cooked in a rich and creamy tomato-based gravy."},
14
+ {"name": "Beef Steak", "category": "HALAL",
15
+ "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/beef_steak.jpg",
16
+ "description": "Juicy beef steak served with mashed potatoes and grilled vegetables."},
17
+ {"name": "Mushroom Soup", "category": "VEGAN",
18
+ "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/mushroom_soup.jpg",
19
+ "description": "Creamy mushroom soup with fresh herbs."},
20
+ {"name": "Tandoori Chicken", "category": "HALAL",
21
+ "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/tandoori_chicken.jpg",
22
+ "description": "Grilled chicken marinated in yogurt and spices, cooked in a tandoor."},
23
+ {"name": "Grilled Veggies", "category": "VEGAN",
24
+ "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/grilled_veggies.jpg",
25
+ "description": "A healthy mix of grilled seasonal vegetables with olive oil."},
26
+ {"name": "Butter Naan", "category": "VEGAN",
27
+ "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/butter_naan.jpg",
28
+ "description": "Soft and buttery flatbread, perfect to pair with any curry."},
29
+ {"name": "Fish Curry", "category": "HALAL",
30
+ "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/fish_curry.jpg",
31
+ "description": "Fresh fish cooked in a spicy and tangy curry."},
32
+ {"name": "Vegetable Salad", "category": "VEGAN",
33
+ "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/vegetable_salad.jpg",
34
+ "description": "A mix of fresh greens, tomatoes, cucumbers, and a light dressing."},
35
+ {"name": "Veg Spring Rolls", "category": "VEGAN",
36
+ "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/veg_spring_rolls.jpg",
37
+ "description": "Crispy spring rolls filled with fresh vegetables."},
38
+ {"name": "Chicken Kebab", "category": "HALAL",
39
+ "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/chicken_kebab.jpg",
40
+ "description": "Juicy chicken kebabs grilled to perfection with a mix of spices."},
41
+ {"name": "Dal Makhani", "category": "VEGAN",
42
+ "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/dal_makhani.jpg",
43
+ "description": "Rich and creamy black lentils slow-cooked with spices."},
44
+ {"name": "Lamb Curry", "category": "HALAL",
45
+ "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/lamb_curry.jpg",
46
+ "description": "Tender lamb pieces cooked in a flavorful curry sauce."},
47
+ {"name": "Mixed Veg Curry", "category": "VEGAN",
48
+ "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/mixed_veg_curry.jpg",
49
+ "description": "A medley of fresh vegetables cooked in a lightly spiced curry."},
50
+ {"name": "Chicken Wings", "category": "HALAL",
51
+ "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/chicken_wings.jpg",
52
+ "description": "Crispy chicken wings tossed in a tangy sauce."},
53
+ {"name": "Aloo Paratha", "category": "VEGAN",
54
+ "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/aloo_paratha.jpg",
55
+ "description": "Indian flatbread stuffed with spiced mashed potatoes."},
56
+ {"name": "Egg Curry", "category": "HALAL",
57
+ "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/egg_curry.jpg",
58
+ "description": "Boiled eggs cooked in a spiced tomato gravy."},
59
+ {"name": "Chickpea Salad", "category": "VEGAN",
60
+ "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/chickpea_salad.jpg",
61
+ "description": "A refreshing salad made with chickpeas, fresh vegetables, and herbs."}
62
  ]
63
 
64
+ # Function to generate row-style dish cards
 
 
 
 
 
 
65
  def display_dishes(category):
66
+ filtered_dishes = [dish for dish in menu_data if category == "ALL" or dish["category"] == category]
67
+ html_content = "<div style='display: flex; flex-wrap: wrap; gap: 15px; justify-content: center;'>"
68
  for dish in filtered_dishes:
69
  html_content += f"""
70
+ <div style='width: 220px; padding: 10px; border: 1px solid #ddd; border-radius: 10px;
71
  background-color: #f9f9f9; text-align: center; cursor: pointer;'
72
  onclick="showPopup('{dish['image']}', '{dish['name']}', '{dish['description']}')">
73
  <img src='{dish['image']}' alt='{dish['name']}'
74
+ style='width: 100%; height: 140px; object-fit: cover; border-radius: 10px;'>
75
  <h4 style='margin: 10px 0; color: #444;'>{dish['name']}</h4>
76
  <p style='color: #666; font-size: 14px;'>{dish['description']}</p>
77
  </div>
 
83
  with gr.Blocks() as demo:
84
  gr.HTML("<h1 style='text-align: center; color: #333;'>🍛 Biryani Hub Menu 🍛</h1>")
85
 
86
+ # Category Buttons
87
  with gr.Row():
88
  btn_all = gr.Button("ALL")
89
  btn_vegan = gr.Button("VEGAN")
90
  btn_halal = gr.Button("HALAL")
91
 
92
+ # Dish display area
93
  dish_display = gr.HTML(value=display_dishes("ALL"))
94
 
95
  # Pop-up HTML and JavaScript
 
117
  </script>
118
  """)
119
 
120
+ # Button actions for filtering
121
  btn_all.click(lambda: gr.update(value=display_dishes("ALL")), outputs=dish_display)
122
  btn_vegan.click(lambda: gr.update(value=display_dishes("VEGAN")), outputs=dish_display)
123
  btn_halal.click(lambda: gr.update(value=display_dishes("HALAL")), outputs=dish_display)