import gradio as gr
# In-memory cart to store added items
cart = []
# Menu data
menu_data = [
{"name": "Vegetable Biryani", "category": "VEGAN",
"image": "https://huggingface.co/spaces/Rammohan0504/dynamic_menu/resolve/main/images/veg_burger.jpg",
"description": "An Indian dish made to be thoroughly enjoyed by anyone who eats it. Made with the best basmati rice and a perfect blend of spices, cooked in original dum style.",
"price": "$13.99"},
]
# Function to add an item to the cart
def add_to_cart(name, price):
cart.append({"name": name, "price": price})
return f"{name} has been added to the cart!", display_cart()
# Function to display the cart
def display_cart():
if not cart:
return "Cart is empty"
html_content = "
"
for item in cart:
html_content += f"""
{item['name']} - {item['price']}
"""
html_content += "
"
return html_content
# Function to display the menu
def display_menu():
html_content = "
"
for dish in menu_data:
html_content += f"""
{dish['name']}
{dish['description']}
Price: {dish['price']}
"""
html_content += "
"
return html_content
# Gradio App
with gr.Blocks() as demo:
gr.HTML("