Spaces:
Sleeping
Sleeping
Update app.py
Browse files131 unmodified lines13213313413513513613713818 unmodified lines157158159160161162163164165166167168169170171172173174160161162163164131 unmodified lines const extrasInputs = document.querySelectorAll('input[name="extras"]:checked'); selectedExtras = Array.from(extrasInputs).map(input => input.value);
fetch("/add_to_cart", { fetch("/submit", { method: "POST", headers: { "Content-Type": "application/json"18 unmodified lines btn_halal.click(lambda: gr.update(value=display_dishes("HALAL")), outputs=dish_display)
# Backend function to handle cart updatesdef add_to_cart_backend(dish_name, spice_level, selected_extras): cart_items.append({ "name": dish_name, "spice_level": spice_level, "extras": selected_extras }) return update_cart()
# Correctly integrate cart updates with Gradio@app.post("/add_to_cart")def add_to_cart_api(data: dict): dish_name = data.get("dish_name", "") spice_level = data.get("spice_level", "") selected_extras = data.get("selected_extras", []) return add_to_cart(dish_name, spice_level, selected_extras) @gr.Interface(fn=add_to_cart, inputs=["text", "text", "list"], outputs="html") def submit(dish_name, spice_level, selected_extras): return add_to_cart(dish_name, spice_level, selected_extras)
demo.launch()app.py+4-16