Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -132,7 +132,7 @@ with gr.Blocks() as demo:
|
|
| 132 |
const extrasInputs = document.querySelectorAll('input[name="extras"]:checked');
|
| 133 |
selectedExtras = Array.from(extrasInputs).map(input => input.value);
|
| 134 |
|
| 135 |
-
fetch("/
|
| 136 |
method: "POST",
|
| 137 |
headers: {
|
| 138 |
"Content-Type": "application/json"
|
|
@@ -157,20 +157,8 @@ with gr.Blocks() as demo:
|
|
| 157 |
btn_halal.click(lambda: gr.update(value=display_dishes("HALAL")), outputs=dish_display)
|
| 158 |
|
| 159 |
# Backend function to handle cart updates
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
"spice_level": spice_level,
|
| 164 |
-
"extras": selected_extras
|
| 165 |
-
})
|
| 166 |
-
return update_cart()
|
| 167 |
-
|
| 168 |
-
# Correctly integrate cart updates with Gradio
|
| 169 |
-
@app.post("/add_to_cart")
|
| 170 |
-
def add_to_cart_api(data: dict):
|
| 171 |
-
dish_name = data.get("dish_name", "")
|
| 172 |
-
spice_level = data.get("spice_level", "")
|
| 173 |
-
selected_extras = data.get("selected_extras", [])
|
| 174 |
-
return add_to_cart(dish_name, spice_level, selected_extras)
|
| 175 |
|
| 176 |
demo.launch()
|
|
|
|
| 132 |
const extrasInputs = document.querySelectorAll('input[name="extras"]:checked');
|
| 133 |
selectedExtras = Array.from(extrasInputs).map(input => input.value);
|
| 134 |
|
| 135 |
+
fetch("/submit", {
|
| 136 |
method: "POST",
|
| 137 |
headers: {
|
| 138 |
"Content-Type": "application/json"
|
|
|
|
| 157 |
btn_halal.click(lambda: gr.update(value=display_dishes("HALAL")), outputs=dish_display)
|
| 158 |
|
| 159 |
# Backend function to handle cart updates
|
| 160 |
+
@gr.Interface(fn=add_to_cart, inputs=["text", "text", "list"], outputs="html")
|
| 161 |
+
def submit(dish_name, spice_level, selected_extras):
|
| 162 |
+
return add_to_cart(dish_name, spice_level, selected_extras)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
demo.launch()
|