File size: 584 Bytes
7324c34
cee8667
1d0a868
7b2be04
7324c34
 
e992434
7324c34
cee8667
7324c34
 
 
 
7b2be04
 
 
de237db
7b2be04
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
import qrcode

def url_to_qr(url):
    qr = qrcode.QRCode(
        version=1,
        error_correction=qrcode.constants.ERROR_CORRECT_L,
        box_size=10,
        border=4,
    )
    qr.add_data(url)
    qr.make(fit=True)

    img = qr.make_image(fill_color="black", back_color="white")
    img_file = "qr_code.png"
    img.save(img_file)

    return img_file

url_input = gr.Textbox(lines=2, label="Enter URL")
output_qr = gr.Image(type="file", label="QR Code")

gr.Interface(fn=url_to_qr, inputs=url_input, outputs=output_qr, title="URL to QR Code").launch()