Rammohan0504 commited on
Commit
e0ae677
·
verified ·
1 Parent(s): e934616

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -102,7 +102,10 @@ with gr.Blocks() as demo:
102
  btn_vegan.click(lambda: display_dishes("VEGAN"), outputs=dish_display)
103
  btn_halal.click(lambda: display_dishes("HALAL"), outputs=dish_display)
104
 
105
- demo.append(gr.HTML(f"""
 
 
 
106
  <div id="popup" style="display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
107
  background-color: white; padding: 20px; border-radius: 10px;
108
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;">
@@ -150,15 +153,8 @@ with gr.Blocks() as demo:
150
  function addToCartFromPopup() {
151
  const spiceLevel = document.querySelector('input[name=spice]:checked')?.value || "None";
152
  const selectedExtras = Array.from(document.querySelectorAll('input[name=extras]:checked')).map(cb => cb.value).join(", ");
153
- fetch('/run/predict', {
154
- method: 'POST',
155
- headers: { 'Content-Type': 'application/json' },
156
- body: JSON.stringify({ data: [selectedItem, selectedPrice, spiceLevel, selectedExtras] })
157
- }).then(response => response.json()).then(data => {
158
- document.querySelector('.cart-html').innerHTML = data.data[0];
159
- alert(selectedItem + " with " + spiceLevel + " spice level and extras: " + selectedExtras + " has been added to the cart!");
160
- closePopup();
161
- });
162
  }
163
  </script>
164
  """))
 
102
  btn_vegan.click(lambda: display_dishes("VEGAN"), outputs=dish_display)
103
  btn_halal.click(lambda: display_dishes("HALAL"), outputs=dish_display)
104
 
105
+ demo.add_component(dish_display)
106
+ demo.add_component(cart_display)
107
+
108
+ demo.add_component(gr.HTML(f"""
109
  <div id="popup" style="display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
110
  background-color: white; padding: 20px; border-radius: 10px;
111
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;">
 
153
  function addToCartFromPopup() {
154
  const spiceLevel = document.querySelector('input[name=spice]:checked')?.value || "None";
155
  const selectedExtras = Array.from(document.querySelectorAll('input[name=extras]:checked')).map(cb => cb.value).join(", ");
156
+ alert(selectedItem + " with " + spiceLevel + " spice level and extras: " + selectedExtras + " has been added to the cart!");
157
+ closePopup();
 
 
 
 
 
 
 
158
  }
159
  </script>
160
  """))