Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -63,11 +63,15 @@ with gr.Blocks() as demo:
|
|
| 63 |
btn_vegan.click(lambda: display_dishes("VEGAN"), outputs=dish_display)
|
| 64 |
btn_halal.click(lambda: display_dishes("HALAL"), outputs=dish_display)
|
| 65 |
|
| 66 |
-
|
| 67 |
-
cart.append(dish_name)
|
| 68 |
-
return cart, update_cart(cart)
|
| 69 |
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
gr.HTML("""
|
| 73 |
<div id='cart-icon' style='position: fixed; top: 10px; right: 10px; cursor: pointer;'>
|
|
@@ -93,6 +97,13 @@ with gr.Blocks() as demo:
|
|
| 93 |
function toggleCartPopup() {
|
| 94 |
const popup = document.getElementById('cart-popup');
|
| 95 |
popup.style.display = popup.style.display === 'block' ? 'none' : 'block';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
}
|
| 97 |
|
| 98 |
function showMenuPopup(name, description, price, image) {
|
|
|
|
| 63 |
btn_vegan.click(lambda: display_dishes("VEGAN"), outputs=dish_display)
|
| 64 |
btn_halal.click(lambda: display_dishes("HALAL"), outputs=dish_display)
|
| 65 |
|
| 66 |
+
selected_item = gr.Textbox(visible=False) # Hidden textbox to hold the selected item
|
|
|
|
|
|
|
| 67 |
|
| 68 |
+
add_to_cart_button = gr.Button("Add to Cart", visible=False) # Hidden button to trigger add_to_cart
|
| 69 |
+
|
| 70 |
+
add_to_cart_button.click(
|
| 71 |
+
add_to_cart,
|
| 72 |
+
inputs=[cart, selected_item],
|
| 73 |
+
outputs=[cart, cart_display]
|
| 74 |
+
)
|
| 75 |
|
| 76 |
gr.HTML("""
|
| 77 |
<div id='cart-icon' style='position: fixed; top: 10px; right: 10px; cursor: pointer;'>
|
|
|
|
| 97 |
function toggleCartPopup() {
|
| 98 |
const popup = document.getElementById('cart-popup');
|
| 99 |
popup.style.display = popup.style.display === 'block' ? 'none' : 'block';
|
| 100 |
+
fetch('/run/predict', {
|
| 101 |
+
method: 'POST',
|
| 102 |
+
headers: { 'Content-Type': 'application/json' },
|
| 103 |
+
body: JSON.stringify({ data: [] })
|
| 104 |
+
}).then(response => response.json()).then(data => {
|
| 105 |
+
document.getElementById('cart-content').innerHTML = data.data[1];
|
| 106 |
+
});
|
| 107 |
}
|
| 108 |
|
| 109 |
function showMenuPopup(name, description, price, image) {
|