Rammohan0504 commited on
Commit
d173270
·
verified ·
1 Parent(s): 84db75d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -11
app.py CHANGED
@@ -154,10 +154,12 @@ with gr.Blocks() as demo:
154
  const quantity = document.getElementById('quantity').value || 1;
155
  const customDescription = document.getElementById('custom-description').value || "None";
156
 
157
- // Pass values to backend
158
- fetch("/flag", {
159
  method: "POST",
160
- headers: {"Content-Type": "application/json"},
 
 
161
  body: JSON.stringify({
162
  dish_name: selectedDish,
163
  spice_level: spiceLevel,
@@ -168,7 +170,7 @@ with gr.Blocks() as demo:
168
  })
169
  .then(response => response.json())
170
  .then(data => {
171
- document.querySelector("#cart-display").innerHTML = data.cart_html;
172
  closePopup();
173
  });
174
  }
@@ -180,11 +182,4 @@ with gr.Blocks() as demo:
180
  btn_vegan.click(lambda: gr.update(value=display_dishes("VEGAN")), outputs=dish_display)
181
  btn_halal.click(lambda: gr.update(value=display_dishes("HALAL")), outputs=dish_display)
182
 
183
- # Handle cart updates via Gradio backend
184
- cart_handler = gr.Interface(
185
- fn=add_to_cart,
186
- inputs=["text", "text", "text", "number", "text"],
187
- outputs="html"
188
- )
189
-
190
  demo.launch()
 
154
  const quantity = document.getElementById('quantity').value || 1;
155
  const customDescription = document.getElementById('custom-description').value || "None";
156
 
157
+ // Update Gradio backend via API call
158
+ fetch("/run/add_to_cart", {
159
  method: "POST",
160
+ headers: {
161
+ "Content-Type": "application/json"
162
+ },
163
  body: JSON.stringify({
164
  dish_name: selectedDish,
165
  spice_level: spiceLevel,
 
170
  })
171
  .then(response => response.json())
172
  .then(data => {
173
+ document.querySelector("#cart-display").innerHTML = data.html;
174
  closePopup();
175
  });
176
  }
 
182
  btn_vegan.click(lambda: gr.update(value=display_dishes("VEGAN")), outputs=dish_display)
183
  btn_halal.click(lambda: gr.update(value=display_dishes("HALAL")), outputs=dish_display)
184
 
 
 
 
 
 
 
 
185
  demo.launch()