Spaces:
Sleeping
Sleeping
Update app.py
Browse files66 unmodified lines67686970707172732 unmodified lines7677787980818283848586878889908586878889909191929345 unmodified lines13914014114314214314466 unmodified lines <h3>${name}</h3> <p>${description}</p> <p style="font-weight: bold;">Price: ${price}</p> <button onclick="addToCart('${name}')" style="padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;"> <button id="add-to-cart-button" style="padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;"> Add to Cart </button> <button onclick="closePopup()" style="padding: 10px 20px; background-color: #dc3545; color: white; border: none; border-radius: 5px; cursor: pointer; margin-left: 10px;">2 unmodified lines `; popup.style.display = "block"; overlay.style.display = "block"; document.getElementById("add-to-cart-button").onclick = async function() { const response = await google.colab.kernel.invokeFunction('add_to_cart', [name], {}); alert(response.data); closePopup(); }; }
function closePopup() { document.getElementById("custom-popup").style.display = "none"; document.getElementById("overlay").style.display = "none"; }
async function addToCart(name) { // Call the Gradio backend function to add item to the cart const response = await google.colab.kernel.invokeFunction('notebook.add_to_cart', [name], {}); alert(response.data); // Show a success message closePopup(); // Close the popup }</script>"""
45 unmodified lines )
# Register the backend function for JavaScript integrationdemo.add_to_cart = add_to_cartdemo.load(lambda: None, inputs=[], outputs=[], live=True) # Dummy to integrate JavaScript
demo.launch()app.py+8-9