Kvikontent commited on
Commit
7b2be04
·
verified ·
1 Parent(s): 4eb6ef0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -16
app.py CHANGED
@@ -1,29 +1,23 @@
1
  import gradio as gr
2
  import qrcode
3
- from PIL import Image
4
 
5
- def generate_qr_code(url):
6
- # Create a QR code instance
7
  qr = qrcode.QRCode(
8
  version=1,
9
  error_correction=qrcode.constants.ERROR_CORRECT_L,
10
  box_size=10,
11
  border=4,
12
  )
13
- # Add data to the QR code
14
  qr.add_data(url)
15
  qr.make(fit=True)
16
- # Generate the QR code image
17
- qr_image = qr.make_image(fill_color="black", back_color="white")
18
- return qr_image
19
 
20
- iface = gr.Interface(
21
- fn=generate_qr_code,
22
- inputs="text",
23
- outputs="image",
24
- title="QR Code Generator",
25
- description="Generate a QR code from a URL",
26
- example="https://www.example.com",
27
- )
28
 
29
- iface.launch()
 
 
 
 
 
 
1
  import gradio as gr
2
  import qrcode
 
3
 
4
+ def url_to_qr(url):
 
5
  qr = qrcode.QRCode(
6
  version=1,
7
  error_correction=qrcode.constants.ERROR_CORRECT_L,
8
  box_size=10,
9
  border=4,
10
  )
 
11
  qr.add_data(url)
12
  qr.make(fit=True)
 
 
 
13
 
14
+ img = qr.make_image(fill_color="black", back_color="white")
15
+ img_file = "qr_code.png"
16
+ img.save(img_file)
 
 
 
 
 
17
 
18
+ return img_file
19
+
20
+ url_input = gr.Textbox(lines=2, label="Enter URL")
21
+ output_qr = gr.Image(type="file", label="QR Code")
22
+
23
+ gr.Interface(fn=url_to_qr, inputs=url_input, outputs=output_qr, title="URL to QR Code").launch()