Rammohan0504 commited on
Commit
5ce65f8
·
verified ·
1 Parent(s): d29ff46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -75,10 +75,10 @@ popup_js = """
75
  overlay.style.display = "block";
76
 
77
  document.getElementById("add-to-cart-button").onclick = async function() {
78
- const response = await fetch('/run/add_to_cart', {
79
- method: 'POST',
80
  body: JSON.stringify({ name }),
81
- headers: { 'Content-Type': 'application/json' }
82
  });
83
  const result = await response.json();
84
  alert(result.data); // Show success message
@@ -140,7 +140,7 @@ with gr.Blocks() as demo:
140
  outputs=cart_display
141
  )
142
 
143
- # Register the add_to_cart function
144
- demo.api("/add_to_cart", add_to_cart)
145
 
146
  demo.launch()
 
75
  overlay.style.display = "block";
76
 
77
  document.getElementById("add-to-cart-button").onclick = async function() {
78
+ const response = await fetch("/run/add_to_cart", {
79
+ method: "POST",
80
  body: JSON.stringify({ name }),
81
+ headers: { "Content-Type": "application/json" }
82
  });
83
  const result = await response.json();
84
  alert(result.data); // Show success message
 
140
  outputs=cart_display
141
  )
142
 
143
+ # Gradio serves all registered functions automatically
144
+ demo.add_to_cart = add_to_cart
145
 
146
  demo.launch()