Spaces:
Sleeping
Sleeping
vincentiusyoshuac
commited on
Commit
•
57d50d1
1
Parent(s):
d07c47b
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
import qrcode
|
2 |
from qrcode.constants import ERROR_CORRECT_L
|
3 |
import streamlit as st
|
4 |
-
|
|
|
5 |
from urllib.parse import urlencode
|
6 |
|
7 |
def generate_contact_qr(contact_info):
|
@@ -135,7 +136,9 @@ def main():
|
|
135 |
}
|
136 |
if st.button("Generate QR Code"):
|
137 |
qr_code = generate_contact_qr(contact_info)
|
138 |
-
|
|
|
|
|
139 |
elif tab == "Email":
|
140 |
st.subheader("Email QR Code")
|
141 |
email_info = {
|
@@ -145,7 +148,9 @@ def main():
|
|
145 |
}
|
146 |
if st.button("Generate QR Code"):
|
147 |
qr_code = generate_email_qr(email_info)
|
148 |
-
|
|
|
|
|
149 |
elif tab == "SMS":
|
150 |
st.subheader("SMS QR Code")
|
151 |
sms_info = {
|
@@ -154,20 +159,26 @@ def main():
|
|
154 |
}
|
155 |
if st.button("Generate QR Code"):
|
156 |
qr_code = generate_sms_qr(sms_info)
|
157 |
-
|
|
|
|
|
158 |
elif tab == "Location":
|
159 |
st.subheader("Location QR Code")
|
160 |
latitude = st.number_input("Latitude", min_value=-90.0, max_value=90.0, step=0.000001)
|
161 |
longitude = st.number_input("Longitude", min_value=-180.0, max_value=180.0, step=0.000001)
|
162 |
if st.button("Generate QR Code"):
|
163 |
qr_code = generate_location_qr(latitude, longitude)
|
164 |
-
|
|
|
|
|
165 |
elif tab == "Link":
|
166 |
st.subheader("Link QR Code")
|
167 |
url = st.text_input("URL")
|
168 |
if st.button("Generate QR Code"):
|
169 |
qr_code = generate_link_qr(url)
|
170 |
-
|
|
|
|
|
171 |
|
172 |
if __name__ == "__main__":
|
173 |
main()
|
|
|
1 |
import qrcode
|
2 |
from qrcode.constants import ERROR_CORRECT_L
|
3 |
import streamlit as st
|
4 |
+
import io
|
5 |
+
from PIL import Image
|
6 |
from urllib.parse import urlencode
|
7 |
|
8 |
def generate_contact_qr(contact_info):
|
|
|
136 |
}
|
137 |
if st.button("Generate QR Code"):
|
138 |
qr_code = generate_contact_qr(contact_info)
|
139 |
+
buf = io.BytesIO()
|
140 |
+
qr_code.save(buf, format="PNG")
|
141 |
+
st.image(buf.getvalue(), use_container_width=True)
|
142 |
elif tab == "Email":
|
143 |
st.subheader("Email QR Code")
|
144 |
email_info = {
|
|
|
148 |
}
|
149 |
if st.button("Generate QR Code"):
|
150 |
qr_code = generate_email_qr(email_info)
|
151 |
+
buf = io.BytesIO()
|
152 |
+
qr_code.save(buf, format="PNG")
|
153 |
+
st.image(buf.getvalue(), use_container_width=True)
|
154 |
elif tab == "SMS":
|
155 |
st.subheader("SMS QR Code")
|
156 |
sms_info = {
|
|
|
159 |
}
|
160 |
if st.button("Generate QR Code"):
|
161 |
qr_code = generate_sms_qr(sms_info)
|
162 |
+
buf = io.BytesIO()
|
163 |
+
qr_code.save(buf, format="PNG")
|
164 |
+
st.image(buf.getvalue(), use_container_width=True)
|
165 |
elif tab == "Location":
|
166 |
st.subheader("Location QR Code")
|
167 |
latitude = st.number_input("Latitude", min_value=-90.0, max_value=90.0, step=0.000001)
|
168 |
longitude = st.number_input("Longitude", min_value=-180.0, max_value=180.0, step=0.000001)
|
169 |
if st.button("Generate QR Code"):
|
170 |
qr_code = generate_location_qr(latitude, longitude)
|
171 |
+
buf = io.BytesIO()
|
172 |
+
qr_code.save(buf, format="PNG")
|
173 |
+
st.image(buf.getvalue(), use_container_width=True)
|
174 |
elif tab == "Link":
|
175 |
st.subheader("Link QR Code")
|
176 |
url = st.text_input("URL")
|
177 |
if st.button("Generate QR Code"):
|
178 |
qr_code = generate_link_qr(url)
|
179 |
+
buf = io.BytesIO()
|
180 |
+
qr_code.save(buf, format="PNG")
|
181 |
+
st.image(buf.getvalue(), use_container_width=True)
|
182 |
|
183 |
if __name__ == "__main__":
|
184 |
main()
|