Spaces:
Running
Running
Commit
•
f4e0ee4
1
Parent(s):
5a99b8a
Upload 2 files
Browse files- app.py +60 -0
- requirements.txt +0 -0
app.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import qrcode as qr
|
3 |
+
from PIL import Image
|
4 |
+
|
5 |
+
st.markdown(
|
6 |
+
f"""
|
7 |
+
<style>
|
8 |
+
.reportview-container .main .block-container{{
|
9 |
+
max-width: 90%;
|
10 |
+
padding-top: 5rem;
|
11 |
+
padding-right: 5rem;
|
12 |
+
padding-left: 5rem;
|
13 |
+
padding-bottom: 5rem;
|
14 |
+
}}
|
15 |
+
img{{
|
16 |
+
max-width:40%;
|
17 |
+
margin-bottom:40px;
|
18 |
+
}}
|
19 |
+
</style>
|
20 |
+
""",
|
21 |
+
unsafe_allow_html=True,
|
22 |
+
)
|
23 |
+
|
24 |
+
st.title("QR Code Generator")
|
25 |
+
|
26 |
+
|
27 |
+
vers = st.number_input("Choose The Version",1,40)
|
28 |
+
box_s = st.number_input("Specify Box Size",1)
|
29 |
+
bord = st.number_input("Specify Size Of Border",1)
|
30 |
+
|
31 |
+
data = st.text_input("Embed Data In The QR Code")
|
32 |
+
|
33 |
+
|
34 |
+
fill = st.color_picker("Pick The Face Color",value="#000000")
|
35 |
+
back = st.color_picker("Pick The Background Color",value="#FFFFFF")
|
36 |
+
|
37 |
+
qr_new = qr.QRCode(version=vers,
|
38 |
+
error_correction=qr.ERROR_CORRECT_H,
|
39 |
+
box_size=box_s,
|
40 |
+
border=bord,)
|
41 |
+
|
42 |
+
# Embed the link using add_data()
|
43 |
+
qr_new.add_data(data)
|
44 |
+
|
45 |
+
# make() is used to create a QR Code
|
46 |
+
qr_new.make(fit=True)
|
47 |
+
|
48 |
+
# Changing the color of the Qr Code
|
49 |
+
|
50 |
+
img = qr_new.make_image(fill_color=fill,back_color=back)
|
51 |
+
|
52 |
+
# save() is used to save QR Code in form of image
|
53 |
+
img.save("img.png")
|
54 |
+
|
55 |
+
with open("img.png","rb") as file:
|
56 |
+
btn = st.download_button("Download",data=file,file_name="qrcode.png",mime="image/png")
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
+
|
requirements.txt
ADDED
Binary file (3.62 kB). View file
|
|