import gradio as gr # Menu data menu_data = [ {"name": "Samosa", "category": "VEGAN", "image": "https://huggingface.co/spaces/Rammohan0504/First-Project/blob/main/pictures/Potato-Samosa.jpg", "description": "A delicious potato samosa with plant-based potato, lettuce.", "price": 8.99}, {"name": "Chicken Biryani", "category": "HALAL", "image": "https://huggingface.co/spaces/Rammohan0504/First-Project/blob/main/pictures/Chicken-Biryani.jpg", "description": "Spicy chicken biryani with aromatic basmati rice and tender chicken pieces.", "price": 12.99}, {"name": "Paneer Butter Masala", "category": "VEGETARIAN", "image": "https://huggingface.co/spaces/Rammohan0504/First-Project/resolve/main/pictures/paneer_butter_masala.jpg", "description": "Soft paneer cubes simmered in a creamy tomato-based gravy, enriched with butter and spices.", "price": 10.99}, {"name": "Chilli Chicken", "category": "HALAL", "image": "https://huggingface.co/spaces/Rammohan0504/First-Project/resolve/main/pictures/chilli_chicken.jpg", "description": "A spicy Indo-Chinese dish featuring fried chicken pieces tossed with peppers and chilies.", "price": 13.99}, {"name": "Veg Manchurian", "category": "VEGAN", "image": "https://huggingface.co/spaces/Rammohan0504/First-Project/resolve/main/pictures/veg_manchurian.jpg", "description": "Deep-fried vegetable balls tossed in a tangy and spicy Indo-Chinese sauce.", "price": 9.99}, {"name": "Fish Curry", "category": "HALAL", "image": "https://huggingface.co/spaces/Rammohan0504/First-Project/resolve/main/pictures/fish_curry.jpg", "description": "A flavorful curry made with tender fish pieces simmered in a spiced coconut gravy.", "price": 14.99}, {"name": "Mutton Biryani", "category": "HALAL", "image": "https://huggingface.co/spaces/Rammohan0504/First-Project/resolve/main/pictures/mutton_biryani.jpg", "description": "Fragrant rice layered with tender mutton and aromatic spices, cooked to perfection.", "price": 15.99}, {"name": "Paneer Biryani", "category": "VEGETARIAN", "image": "https://huggingface.co/spaces/Rammohan0504/First-Project/resolve/main/pictures/paneer_biryani.jpg", "description": "A delightful biryani made with marinated paneer cubes and basmati rice, infused with spices.", "price": 11.99}, {"name": "Onion Pakoda", "category": "VEGAN", "image": "https://huggingface.co/spaces/Rammohan0504/First-Project/resolve/main/pictures/onion_pakoda.jpg", "description": "Crispy deep-fried onion fritters, seasoned with spices, a popular tea-time snack.", "price": 5.99}, {"name": "Chilli Gobi", "category": "VEGAN", "image": "https://huggingface.co/spaces/Rammohan0504/First-Project/resolve/main/pictures/chilli_gobi.jpg", "description": "Crispy cauliflower florets tossed in a spicy and tangy sauce, an Indo-Chinese favorite.", "price": 9.99}, {"name": "Potato Samosa", "category": "VEGETARIAN", "image": "https://huggingface.co/spaces/Rammohan0504/First-Project/resolve/main/pictures/potato_samosa.jpg", "description": "Crispy pastry filled with a spiced potato mixture, deep-fried to golden perfection.", "price": 4.99}, {"name": "Prawn Fry", "category": "HALAL", "image": "https://huggingface.co/spaces/Rammohan0504/First-Project/resolve/main/pictures/prawn_fry.jpg", "description": "Spicy and crispy fried prawns, marinated with a blend of spices and herbs.", "price": 14.99}, {"name": "Sukka Gosht (Goat)", "category": "HALAL", "image": "https://huggingface.co/spaces/Rammohan0504/First-Project/resolve/main/pictures/sukka_gosht.jpg", "description": "Dry goat meat preparation cooked with a medley of spices, offering a rich and hearty flavor.", "price": 16.99}, {"name": "Channa Masala", "category": "VEGETARIAN", "image": "https://huggingface.co/spaces/Rammohan0504/First-Project/resolve/main/pictures/channa_masala.jpg", "description": "A hearty curry made with chickpeas simmered in a spiced tomato gravy.", "price": 8.99}, {"name": "Vegetable Biryani", "category": "VEGAN", "image": "https://huggingface.co/spaces/Rammohan0504/First-Project/resolve/main/pictures/veg_biryani.jpg", "description": "A medley of vegetables and basmati rice cooked with aromatic spices, a vegetarian delight.", "price": 10.99}, {"name": "Chicken Manchurian", "category": "HALAL", "image": "https://huggingface.co/spaces/Rammohan0504/First-Project/resolve/main/pictures/chicken_manchurian.jpg", "description": "A popular Indo-Chinese dish featuring fried chicken pieces tossed in a tangy and spicy sauce.", "price": 13.99}, ] # Cart management cart = [] def add_item_to_cart(item_name, price, extras="None"): for item in cart: if item['name'] == item_name and item['extras'] == extras: item['count'] += 1 return update_cart() cart.append({"name": item_name, "price": price, "extras": extras, "count": 1}) return update_cart() def update_cart(): if not cart: return "

Your cart is empty.

" cart_html = "" total_price = 0 for item in cart: item_total = item['price'] * item['count'] total_price += item_total cart_html += f"" cart_html += f"
ItemExtrasPriceCountTotal
{item['name']}{item['extras']}${item['price']}{item['count']}${item_total:.2f}
Total${total_price:.2f}
" return cart_html # Function to filter dishes by category def filter_dishes(category): if category == "ALL": return menu_data return [dish for dish in menu_data if dish["category"] == category] # Function to display dishes def display_dishes(category="ALL"): filtered_dishes = filter_dishes(category) html_content = "
" for dish in filtered_dishes: html_content += f"""
{dish[

{dish['name']}

{dish['description']}

Price: ${dish['price']}

""" html_content += "
" return html_content # Main Gradio App with gr.Blocks() as demo: gr.HTML("

Dynamic Menu with Cart

") with gr.Row(): btn_all = gr.Button("ALL") btn_vegan = gr.Button("VEGAN") btn_halal = gr.Button("HALAL") dish_display = gr.HTML(value=display_dishes()) btn_all.click(lambda: display_dishes("ALL"), outputs=dish_display) btn_vegan.click(lambda: display_dishes("VEGAN"), outputs=dish_display) btn_halal.click(lambda: display_dishes("HALAL"), outputs=dish_display) cart_display = gr.HTML(value="

Your cart is empty.

") def add_to_cart_handler(item_name, price): return add_item_to_cart(item_name, price) gr.HTML("""
Cart
""") demo.launch()