Rammohan0504 commited on
Commit
a33c300
·
verified ·
1 Parent(s): 12901d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -93
app.py CHANGED
@@ -82,9 +82,7 @@ menu_data = [
82
 
83
 
84
 
85
- # Spice levels and extras
86
- spice_levels = ["American Mild", "American Medium", "American Spicy",
87
- "Indian Mild", "Indian Medium", "Indian Spicy", "Indian Very Spicy"]
88
  extras = [
89
  {"name": "Extra Raitha 4oz", "price": "$1.00"},
90
  {"name": "Extra Raitha 8oz", "price": "$2.00"},
@@ -122,56 +120,6 @@ popup_js = """
122
  `).join("")}
123
  </div>
124
 
125
- <button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer;">Add to Cart</button>
126
- <button onclick="closePopup()" style="margin-top: 20px; margin-left: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;">Close</button>
127
- `;
128
- popup.style.display = "block";
129
- overlay.style.display = "block";
130
- }
131
-
132
- function closePopup() {
133
- const popup = document.getElementById("custom-popup");
134
- const overlay = document.getElementById("overlay");
135
- popup.style.display = "none";
136
- overlay.style.display = "none";
137
- }
138
- </script>
139
- """
140
-
141
- # HTML for popup modal
142
- popup_html = """
143
- <div id="overlay" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: none; z-index: 999;"></div>
144
- <div id="custom-popup"
145
- style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60%; max-width: 600px; background: white; padding: 20px; border-radius: 10px; box-shadow: 0px 4px 6px rgba(0,0,0,0.1); display: none; z-index: 1000; text-align: center;">
146
- </div>
147
- """
148
-
149
- # Generate dish cards
150
- import gradio as gr
151
-
152
- menu_data = [
153
- {"name": "Veg Burger", "category": "VEGAN",
154
- "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/veg_burger.jpg",
155
- "description": "A delicious vegan burger with plant-based patty, lettuce, and tomato.",
156
- "price": "$8.99"},
157
- {"name": "Chicken Biryani", "category": "HALAL",
158
- "image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/chicken_biryani.jpg",
159
- "description": "Spicy chicken biryani with aromatic basmati rice and tender chicken pieces.",
160
- "price": "$12.99"}
161
- # Add more items as needed
162
- ]
163
-
164
- # JavaScript for popup modal
165
- popup_js = """
166
- <script>
167
- function showPopup(name, description, price, image) {
168
- const popup = document.getElementById("custom-popup");
169
- const overlay = document.getElementById("overlay");
170
- popup.innerHTML = `
171
- <img src="${image}" alt="${name}" style="width: auto; height: 250px; border-radius: 10px; margin-bottom: 10px;">
172
- <h3 style="margin-top: 10px;">${name}</h3>
173
- <p>${description}</p>
174
- <p style="font-weight: bold;">Price: ${price}</p>
175
  <button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;">Add to Cart</button>
176
  <button onclick="closePopup()" style="margin-top: 20px; margin-left: 10px; padding: 10px 20px; background-color: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer;">Close</button>
177
  `;
@@ -197,57 +145,36 @@ popup_html = """
197
  """
198
 
199
  # Generate dish cards
200
- def display_dishes(category):
201
  html_content = "<div style='display: flex; flex-direction: column; gap: 20px; width: 80%; margin: auto;'>"
202
  for dish in menu_data:
203
- if category == "ALL" or dish["category"] == category:
204
- html_content += f"""
205
- <div style='display: flex; align-items: center; justify-content: space-between; padding: 20px; border: 1px solid #ddd; border-radius: 10px; background-color: #f9f9f9;'>
206
- <div style='flex: 3; text-align: left;'>
207
- <h3 style='margin: 0; font-size: 20px;'>{dish['name']}</h3>
208
- <p style='margin: 5px 0; font-size: 14px; color: #555;'>{dish['description']}</p>
209
- <p style='margin: 0; font-size: 16px; font-weight: bold;'>Price: {dish['price']}</p>
210
- </div>
211
- <div style='flex: 1; display: flex; flex-direction: row; align-items: center;'>
212
- <img src='{dish['image']}' alt='{dish['name']}' style='width: 120px; height: 80px; object-fit: cover; border-radius: 10px; margin-bottom: 10px;'>
213
- <button onclick="showPopup('{dish['name']}', '{dish['description']}', '{dish['price']}', '{dish['image']}')"
214
- style='padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;'>
215
- Add
216
- </button>
217
- </div>
218
  </div>
219
- """
 
220
  html_content += "</div>"
221
  return html_content
222
-
223
  # Main Gradio App
224
  with gr.Blocks() as demo:
225
  gr.HTML(popup_html) # Add the popup container and overlay
226
  gr.HTML(popup_js) # Add the JavaScript
227
 
228
- gr.HTML("<h1 style='text-align: center;'>🍛 Biryani Hub Menu 🍛</h1>")
229
-
230
- # Buttons for filtering categories
231
- with gr.Row():
232
- btn_all = gr.Button("ALL")
233
- btn_vegan = gr.Button("VEGAN")
234
- btn_halal = gr.Button("HALAL")
235
 
236
  # Dish display
237
- dish_display = gr.HTML(value=display_dishes("ALL"))
238
-
239
- # Button click events
240
- btn_all.click(
241
- lambda: gr.update(value=display_dishes("ALL")),
242
- outputs=dish_display
243
- )
244
- btn_vegan.click(
245
- lambda: gr.update(value=display_dishes("VEGAN")),
246
- outputs=dish_display
247
- )
248
- btn_halal.click(
249
- lambda: gr.update(value=display_dishes("HALAL")),
250
- outputs=dish_display
251
- )
252
 
253
  demo.launch()
 
82
 
83
 
84
 
85
+ spice_levels = ["American Mild", "American Medium", "American Spicy", "Indian Mild", "Indian Medium", "Indian Spicy", "Indian Very Spicy"]
 
 
86
  extras = [
87
  {"name": "Extra Raitha 4oz", "price": "$1.00"},
88
  {"name": "Extra Raitha 8oz", "price": "$2.00"},
 
120
  `).join("")}
121
  </div>
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  <button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;">Add to Cart</button>
124
  <button onclick="closePopup()" style="margin-top: 20px; margin-left: 10px; padding: 10px 20px; background-color: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer;">Close</button>
125
  `;
 
145
  """
146
 
147
  # Generate dish cards
148
+ def display_dishes():
149
  html_content = "<div style='display: flex; flex-direction: column; gap: 20px; width: 80%; margin: auto;'>"
150
  for dish in menu_data:
151
+ html_content += f"""
152
+ <div style='display: flex; align-items: center; justify-content: space-between; padding: 20px; border: 1px solid #ddd; border-radius: 10px; background-color: #f9f9f9;'>
153
+ <div style='flex: 3; text-align: left;'>
154
+ <h3 style='margin: 0; font-size: 20px;'>{dish['name']}</h3>
155
+ <p style='margin: 5px 0; font-size: 14px; color: #555;'>{dish['description']}</p>
156
+ <p style='margin: 0; font-size: 16px; font-weight: bold;'>Price: {dish['price']}</p>
157
+ </div>
158
+ <div style='flex: 1; display: flex; flex-direction: column; align-items: center;'>
159
+ <img src='{dish['image']}' alt='{dish['name']}' style='width: 120px; height: 80px; object-fit: cover; border-radius: 10px; margin-bottom: 10px;'>
160
+ <button onclick="showPopup('{dish['name']}', '{dish['description']}', '{dish['price']}', '{dish['image']}')"
161
+ style='padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;'>
162
+ Add
163
+ </button>
 
 
164
  </div>
165
+ </div>
166
+ """
167
  html_content += "</div>"
168
  return html_content
169
+
170
  # Main Gradio App
171
  with gr.Blocks() as demo:
172
  gr.HTML(popup_html) # Add the popup container and overlay
173
  gr.HTML(popup_js) # Add the JavaScript
174
 
175
+ gr.HTML("<h1 style='text-align: center;'>\ud83c\udf5b Biryani Hub Menu \ud83c\udf5b</h1>")
 
 
 
 
 
 
176
 
177
  # Dish display
178
+ dish_display = gr.HTML(value=display_dishes())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
 
180
  demo.launch()