Rammohan0504 commited on
Commit
28fdec6
·
verified ·
1 Parent(s): 78c1205

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -60,7 +60,7 @@ def display_dishes(category="ALL"):
60
  <h4>{dish['name']}</h4>
61
  <p>{dish['description']}</p>
62
  <p><strong>Price:</strong> ${dish['price']}</p>
63
- <button onclick="addToCart('{dish['name']}', {dish['price']})" style='padding: 5px 10px; background-color: #28a745; color: white; border: none; border-radius: 3px;'>Add to Cart</button>
64
  </div>
65
  """
66
  html_content += "</div>"
@@ -86,9 +86,9 @@ with gr.Blocks() as demo:
86
  def add_to_cart_handler(item_name, price):
87
  return add_item_to_cart(item_name, price)
88
 
89
- gr.Interface(
90
  fn=add_to_cart_handler,
91
- inputs=[gr.Textbox(visible=False, label="Item Name"), gr.Number(visible=False, label="Price")],
92
  outputs=cart_display,
93
  )
94
 
@@ -114,7 +114,7 @@ with gr.Blocks() as demo:
114
  headers: { 'Content-Type': 'application/json' },
115
  body: JSON.stringify({ data: [name, price] })
116
  }).then(response => response.json()).then(data => {
117
- document.getElementById('cart-content').innerHTML = data.data;
118
  alert(`${name} has been added to your cart.`);
119
  });
120
  }
 
60
  <h4>{dish['name']}</h4>
61
  <p>{dish['description']}</p>
62
  <p><strong>Price:</strong> ${dish['price']}</p>
63
+ <button onclick="addToCart('{dish['name']}', '{dish['price']}')" style='padding: 5px 10px; background-color: #28a745; color: white; border: none; border-radius: 3px;'>Add to Cart</button>
64
  </div>
65
  """
66
  html_content += "</div>"
 
86
  def add_to_cart_handler(item_name, price):
87
  return add_item_to_cart(item_name, price)
88
 
89
+ add_to_cart_interface = gr.Interface(
90
  fn=add_to_cart_handler,
91
+ inputs=[gr.Textbox(visible=False, label="Item Name"), gr.Textbox(visible=False, label="Price")],
92
  outputs=cart_display,
93
  )
94
 
 
114
  headers: { 'Content-Type': 'application/json' },
115
  body: JSON.stringify({ data: [name, price] })
116
  }).then(response => response.json()).then(data => {
117
+ document.getElementById('cart-content').innerHTML = data.data[0];
118
  alert(`${name} has been added to your cart.`);
119
  });
120
  }