meebox commited on
Commit
863e85e
·
1 Parent(s): 05ff8c8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import qrcode
2
+ import gradio as gr
3
+
4
+ def url_to_qrcode(url, box_size):
5
+ q = qrcode.QRCode(
6
+ version = None,
7
+ error_correction=qrcode.ERROR_CORRECT_H,
8
+ box_size=box_size,
9
+ )
10
+ q.add_data(url)
11
+ q.make(fit=True)
12
+ img = q.make_image()
13
+ img.save("qrcode.png")
14
+ return "test.png"
15
+
16
+ ui = gr.Interface(
17
+ fn=url_to_qrcode,
18
+ inputs=[
19
+ gr.Text(
20
+ label="請輸入 URL(一行一個):"
21
+ ),
22
+ gr.Slider(
23
+ label="QRcode 邊邊點數:",
24
+ minimum=40,
25
+ maximum=300,
26
+ value=120
27
+ )
28
+ ],
29
+ outputs=gr.Image(type="filepath")
30
+ )
31
+ ui.launch(share=True)
32
+