qrcode / app.py
meebox's picture
Create app.py
863e85e
raw
history blame
753 Bytes
import qrcode
import gradio as gr
def url_to_qrcode(url, box_size):
q = qrcode.QRCode(
version = None,
error_correction=qrcode.ERROR_CORRECT_H,
box_size=box_size,
)
q.add_data(url)
q.make(fit=True)
img = q.make_image()
img.save("qrcode.png")
return "test.png"
ui = gr.Interface(
fn=url_to_qrcode,
inputs=[
gr.Text(
label="請輸入 URL(一行一個):"
),
gr.Slider(
label="QRcode 邊邊點數:",
minimum=40,
maximum=300,
value=120
)
],
outputs=gr.Image(type="filepath")
)
ui.launch(share=True)