create an app that can generate a qr code based on an input. so Convert user-entered text or URLs into QR codes that they can download.
Drop files here
or click to upload
import streamlit as st
import qrcode
import io
st.title('QR Code Generator')
# User input
user_input = st.text_input('Enter URL or text to generate QR code:')
if st.button('Generate QR Code'):
if user_input:
# Generate QR code
qr = qrcode.QRCode(version=1, box_size=10, border=5)
qr.add_data(user_input)
qr.make(fit=True)
img = qr.make_image(fill='black', back_color='white')
# Save to a BytesIO object
buf = io.BytesIO()
img.save(buf, format="PNG")
buf.seek(0)
# Display QR code
st.image(buf, caption='Your QR Code', use_column_width=True)
# Download button
st.download_button(
label='Download QR Code',
data=buf,
file_name='qr_code.png',
mime='image/png'
)
else:
st.warning('Please enter some text or URL to generate a QR code.')
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?