Spaces:
Sleeping
Sleeping
Update app.py
Browse files66 unmodified lines676869707172732 unmodified lines7677787980818283848586878889909192939445 unmodified lines14014114214314414566 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;">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";}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 cartconst response = await google.colab.kernel.invokeFunction('notebook.add_to_cart', [name], {});alert(response.data); // Show a success messageclosePopup(); // Close the popup}</script>"""45 unmodified lines)# Register the backend function for JavaScript integrationdemo.add_to_cart = add_to_cartdemo.launch()66 unmodified lines676869707172732 unmodified lines76777879808182838485868788899091929345 unmodified lines13914014114214314466 unmodified lines<h3>${name}</h3><p>${description}</p><p style="font-weight: bold;">Price: ${price}</p><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";}</script>"""45 unmodified lines)# Register the backend function for JavaScript integrationdemo.load(lambda: None, inputs=[], outputs=[], live=True) # Dummy to integrate JavaScriptdemo.launch()
app.py+8-9