-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
32 lines (25 loc) · 1.06 KB
/
main.py
File metadata and controls
32 lines (25 loc) · 1.06 KB
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
import streamlit as st
import requests
from PIL import Image
from io import BytesIO
st.set_page_config(page_title="QR Code Generator", page_icon=":white_medium_square:", layout="centered")
st.title("QR Code Generator")
user_input = st.text_input("Enter the link to generate its QR code:")
if user_input:
response = requests.get(f"https://us-central1-test-da9ec.cloudfunctions.net/qrcode-python?link={user_input}")
# Check if the request was successful
if response.status_code == 200:
img = Image.open(BytesIO(response.content))
st.image(img, caption="Generated QR Code")
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"
)
else:
st.error("Failed to generate QR Code. Please try again.")
st.markdown("Built with ❤️ by [Pratik Kale](https://pratikkale.in) | [Source Code](https://github.com/pratikkalein/cloud-function-demo)")