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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -28
app.py CHANGED
@@ -82,7 +82,9 @@ menu_data = [
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"},
@@ -96,7 +98,7 @@ popup_js = """
96
  function showPopup(name, description, price, image) {
97
  const popup = document.getElementById("custom-popup");
98
  const overlay = document.getElementById("overlay");
99
- popup.innerHTML = `
100
  <img src="${image}" alt="${name}" style="width: auto; height: 250px; border-radius: 10px; margin-bottom: 10px;">
101
  <h3 style="margin-top: 10px;">${name}</h3>
102
  <p>${description}</p>
@@ -104,25 +106,25 @@ popup_js = """
104
 
105
  <h4 style="margin-top: 20px;">Choose a Spice Level</h4>
106
  <div style="display: flex; flex-wrap: wrap; gap: 10px;">
107
- ${["American Mild", "American Medium", "American Spicy", "Indian Mild", "Indian Medium", "Indian Spicy", "Indian Very Spicy"].map(spice => `
108
  <label style="margin-right: 10px;">
109
  <input type="radio" name="spice" value="${spice}"> ${spice}
110
  </label>
111
- `).join("")}
112
  </div>
113
 
114
  <h4 style="margin-top: 20px;">Choose Extras</h4>
115
  <div style="display: flex; flex-wrap: wrap; gap: 10px;">
116
- ${["Extra Raitha 4oz + $1.00", "Extra Raitha 8oz + $2.00", "Extra Onion + $1.00", "Extra Onion & Lemon + $2.00"].map(extra => `
117
  <label style="margin-right: 10px;">
118
  <input type="checkbox" name="extras" value="${extra}"> ${extra}
119
  </label>
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
- `;
126
  popup.style.display = "block";
127
  overlay.style.display = "block";
128
  }
@@ -145,25 +147,26 @@ popup_html = """
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
 
@@ -172,9 +175,30 @@ 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()
 
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"},
 
98
  function showPopup(name, description, price, image) {
99
  const popup = document.getElementById("custom-popup");
100
  const overlay = document.getElementById("overlay");
101
+ popup.innerHTML =
102
  <img src="${image}" alt="${name}" style="width: auto; height: 250px; border-radius: 10px; margin-bottom: 10px;">
103
  <h3 style="margin-top: 10px;">${name}</h3>
104
  <p>${description}</p>
 
106
 
107
  <h4 style="margin-top: 20px;">Choose a Spice Level</h4>
108
  <div style="display: flex; flex-wrap: wrap; gap: 10px;">
109
+ ${["American Mild", "American Medium", "American Spicy", "Indian Mild", "Indian Medium", "Indian Spicy", "Indian Very Spicy"].map(spice =>
110
  <label style="margin-right: 10px;">
111
  <input type="radio" name="spice" value="${spice}"> ${spice}
112
  </label>
113
+ ).join("")}
114
  </div>
115
 
116
  <h4 style="margin-top: 20px;">Choose Extras</h4>
117
  <div style="display: flex; flex-wrap: wrap; gap: 10px;">
118
+ ${["Extra Raitha 4oz + $1.00", "Extra Raitha 8oz + $2.00", "Extra Onion + $1.00", "Extra Onion & Lemon + $2.00"].map(extra =>
119
  <label style="margin-right: 10px;">
120
  <input type="checkbox" name="extras" value="${extra}"> ${extra}
121
  </label>
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
  }
 
147
  """
148
 
149
  # Generate dish cards
150
+ def display_dishes(category):
151
  html_content = "<div style='display: flex; flex-direction: column; gap: 20px; width: 80%; margin: auto;'>"
152
  for dish in menu_data:
153
+ if category == "ALL" or dish["category"] == category:
154
+ html_content += f"""
155
+ <div style='display: flex; align-items: center; justify-content: space-between; padding: 20px; border: 1px solid #ddd; border-radius: 10px; background-color: #f9f9f9;'>
156
+ <div style='flex: 3; text-align: left;'>
157
+ <h3 style='margin: 0; font-size: 20px;'>{dish['name']}</h3>
158
+ <p style='margin: 5px 0; font-size: 14px; color: #555;'>{dish['description']}</p>
159
+ <p style='margin: 0; font-size: 16px; font-weight: bold;'>Price: {dish['price']}</p>
160
+ </div>
161
+ <div style='flex: 1; flex-direction: row; text-align: center;'>
162
+ <img src='{dish['image']}' alt='{dish['name']}' style='width: 120px; height: 80px; object-fit: cover; border-radius: 10px;'>
163
+ <button onclick="showPopup('{dish['name']}', '{dish['description']}', '{dish['price']}', '{dish['image']}')"
164
+ style='margin-top: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;'>
165
+ Add
166
+ </button>
167
+ </div>
168
  </div>
169
+ """
 
 
 
 
 
 
 
 
170
  html_content += "</div>"
171
  return html_content
172
 
 
175
  gr.HTML(popup_html) # Add the popup container and overlay
176
  gr.HTML(popup_js) # Add the JavaScript
177
 
178
+ gr.HTML("<h1 style='text-align: center;'>🍛 Biryani Hub Menu 🍛</h1>")
179
+
180
+ # Buttons for filtering categories
181
+ with gr.Row():
182
+ btn_all = gr.Button("ALL")
183
+ btn_vegan = gr.Button("VEGAN")
184
+ btn_halal = gr.Button("HALAL")
185
 
186
  # Dish display
187
+ dish_display = gr.HTML(value=display_dishes("ALL"))
188
+
189
+ # Button click events
190
+ btn_all.click(
191
+ lambda: gr.update(value=display_dishes("ALL")),
192
+ outputs=dish_display
193
+ )
194
+ btn_vegan.click(
195
+ lambda: gr.update(value=display_dishes("VEGAN")),
196
+ outputs=dish_display
197
+ )
198
+ btn_halal.click(
199
+ lambda: gr.update(value=display_dishes("HALAL")),
200
+ outputs=dish_display
201
+ )
202
+
203
+ demo.launch()
204