Spaces:
Sleeping
Sleeping
Update app.py
Browse files131 unmodified lines13213313413513613713818 unmodified lines157158159160161162163164165166167168169170171172173174175176131 unmodified linesconst extrasInputs = document.querySelectorAll('input[name="extras"]:checked');selectedExtras = Array.from(extrasInputs).map(input => input.value);fetch("/add_to_cart", {method: "POST",headers: {"Content-Type": "application/json"18 unmodified linesbtn_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)demo.launch()131 unmodified lines13213313413513613713818 unmodified lines157158159160161162163164131 unmodified linesconst extrasInputs = document.querySelectorAll('input[name="extras"]:checked');selectedExtras = Array.from(extrasInputs).map(input => input.value);fetch("/submit", {method: "POST",headers: {"Content-Type": "application/json"18 unmodified linesbtn_halal.click(lambda: gr.update(value=display_dishes("HALAL")), outputs=dish_display)# Backend function to handle cart updates@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