QR codes are everywhere โ from restaurant menus to event passes. But what if you could make your own QR code generator with full control over colors and content?
In this quick tutorial, Iโll show you how to build a fully functional QR Code Generator app using Python and Streamlit. It's beginner-friendly and runs in your browser!
๐ What Weโll Build
A web app that lets you:
๐ค Enter any text or URL.
๐จ Choose custom colors for the QR code and background.
๐ฅ Download the generated QR code image.
Hereโs a sneak peek of what it will look like:
๐ง Technologies Used
Python.
qrcode โ for generating QR codes.
Pillow (PIL) โ for image manipulation.
Streamlit โ for turning Python into a web app.
๐งฉ Step 1: Install the Dependencies
First, install the required Python packages:
pip install streamlit qrcode pillow
๐งพ Step 2: The Code
Create a file called qr_generator.py and paste the following code:
import streamlit as st
import qrcode
from PIL import Image
from io import BytesIO
st.title("๐งพ QR Code Generator")
data = st.text_input("Enter text or URL:")
fill_color = st.color_picker("Pick QR color", "#000000")
bg_color = st.color_picker("Pick background color", "#ffffff")
if st.button("Generate QR Code") and data:
qr = qrcode.QRCode(box_size=10, border=4)
qr.add_data(data)
qr.make(fit=True)
img = qr.make_image(fill_color=fill_color, back_color=bg_color).convert("RGB")
st.image(img)
buffer = BytesIO()
img.save(buffer, format="PNG")
buffer.seek(0)
st.download_button(
label="Download QR Code",
data=buffer,
file_name="qr_code.png",
mime="image/png"
)
๐งช Step 3: Run the App
Just run this command in the terminal:
streamlit run qr_generator.py
Then open the browser, and youโll see your own live QR generator ๐.
Screenshots:
๐ฎ Bonus Ideas
Add a logo to the center of the QR.
Save a history of generated codes.
Turn it into a Chrome extension.
Deploy it with Streamlit Community Cloud.
๐ซถ Final Thoughts
With just a few lines of Python, youโve built a cool and useful tool. You can now generate customized QR codes anytime โ perfect for business cards, events, links, and more.
If you liked this, give it a โค๏ธ and follow me for more beginner-friendly Python + Streamlit projects.
Have questions or want to collab? Drop a comment below ๐
Top comments (0)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.