Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
//
|
| 158 |
-
fetch("/
|
| 159 |
method: "POST",
|
| 160 |
-
headers: {
|
|
|
|
|
|
|
| 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.
|
| 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()
|