File size: 4,304 Bytes
0221084 f47bb01 0221084 4dc19a6 0221084 4dc19a6 f47bb01 0221084 4dc19a6 0221084 4dc19a6 1342553 0221084 1342553 68f0820 1342553 4dc19a6 f47bb01 0221084 68f0820 1342553 68f0820 1342553 68f0820 1342553 0221084 68f0820 4dc19a6 0221084 4dc19a6 1342553 4dc19a6 0221084 68f0820 4dc19a6 0221084 68f0820 4dc19a6 0221084 4dc19a6 0221084 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | import streamlit as st
import sqlite3
import qrcode
import io
# SQLite setup
DB_NAME = "cafe.db"
def init_db():
conn = sqlite3.connect(DB_NAME)
c = conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS reservations (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
guests INTEGER,
date TEXT,
time TEXT
)''')
conn.commit()
conn.close()
def get_db_connection():
return sqlite3.connect(DB_NAME)
def generate_qr_code(link):
qr = qrcode.make(link)
buf = io.BytesIO()
qr.save(buf)
buf.seek(0)
return buf
# Initialize DB on startup
init_db()
# Constants
GOOGLE_MAPS_URL = "https://www.google.com/maps/place/Brew+%26+Bite+Cafe"
WHATSAPP_LINK = "https://wa.me/923001234567?text=Hi%20I%20want%20to%20place%20an%20order"
# Menu
deals = {
"DEAL-1": "Small Pizza (Special) + 345ml Drink - Rs. 749",
"DEAL-2": "Medium Pizza (Special) + 500ml Drink - Rs. 1199",
"DEAL-3": "Large Pizza (Special) + 1L Drink - Rs. 1799",
"DEAL-4": "Large Pizza + Medium Pizza + 1.5L Drink - Rs. 2899",
"DEAL-5": "Two Large Pizzas (Special) + 1.5L Drink - Rs. 3399",
"DEAL-6": "X-Large Pizza (Special) + 2 Chicken Burgers + 1.5L Drink - Rs. 3199",
"DEAL-7": "Pasta + Large Pizza + 2 Chicken Burgers + 1.5L Drink + Fries - Rs. 2499",
"DEAL-8": "Zinger Burger + 345ml Drink + Fries - Rs. 649",
"DEAL-9": "Smoky Sensation or Famous Star Burger + 345ml Drink + Fries - Rs. 849",
"DEAL-10": "Tabahi Burger + 345ml Drink + Fries - Rs. 1049",
"DEAL-11": "3 Zinger Burgers + 1L Drink + Behari Roll + Fries - Rs. 1999",
"DEAL-12": "3 Smoky Sensation or Famous Star Burgers + Behari Roll + 1L Drink + Fries - Rs. 2499"
}
sauces = [
"Ranch Sauce - Rs. 70",
"Garlic Sauce - Rs. 70",
"Dip Sauce - Rs. 70",
"Flaming Sauce - Rs. 70",
"Peeri Peeri - Rs. 70",
"Shahi Sauce - Rs. 70"
]
drinks = [
"345ml - Rs. 80",
"500ml - Rs. 120",
"1 Liter - Rs. 180",
"1.5 Liter - Rs. 220"
]
waters = [
"500ml - Rs. 60",
"1.5 Liter - Rs. 100"
]
# UI
st.set_page_config(page_title="CheezeMan Cafe Chatbot", layout="centered")
st.title("Welcome to CheezeMan Cafe Chatbot")
# Replace sidebar with main menu buttons
st.markdown("### Main Menu")
option = st.selectbox("Choose an action:", [
"View Full Menu",
"Place Order",
"Ask a Question",
"Reserve Table",
"Our Location",
"Scan Menu QR"
])
if option == "View Full Menu":
st.subheader("Deals")
for name, details in deals.items():
st.write(f"{name}: {details}")
st.subheader("Sauces & Add-ons")
for item in sauces:
st.write(f"- {item}")
st.subheader("Drinks")
for item in drinks:
st.write(f"- {item}")
st.subheader("Water")
for item in waters:
st.write(f"- {item}")
elif option == "Place Order":
st.subheader("WhatsApp Order")
st.markdown(f"[Click Here to Place Order on WhatsApp]({WHATSAPP_LINK})")
elif option == "Ask a Question":
st.subheader("Ask a Question")
question = st.text_area("Ask us anything!")
if st.button("Submit"):
st.success("We'll get back to you shortly via WhatsApp or Email!")
elif option == "Reserve Table":
st.subheader("Reserve Your Table")
name = st.text_input("Name")
guests = st.number_input("Number of Guests", min_value=1, max_value=20)
date = st.date_input("Date")
time = st.time_input("Time")
if st.button("Book Table"):
conn = get_db_connection()
cursor = conn.cursor()
cursor.execute("INSERT INTO reservations (name, guests, date, time) VALUES (?, ?, ?, ?)",
(name, guests, str(date), str(time)))
conn.commit()
conn.close()
st.success("Table reserved successfully!")
elif option == "Our Location":
st.subheader("Find Us Here")
st.markdown(f"[Open in Google Maps]({GOOGLE_MAPS_URL})")
elif option == "Scan Menu QR":
st.subheader("Scan to Open Menu")
qr_buffer = generate_qr_code("https://your-cafe-website.com/chatbot")
st.image(qr_buffer, caption="Scan with your phone to view the menu")
st.download_button("Download QR Code", qr_buffer, "menu_qr.png", mime="image/png")
|