Rahatara commited on
Commit
0ee98d2
·
verified ·
1 Parent(s): 85deddf

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import qrcode
3
+ from PIL import Image
4
+ import io
5
+
6
+ def generate_qr(link):
7
+ if link.strip() == "":
8
+ return None
9
+
10
+ # Create QR
11
+ qr = qrcode.QRCode(
12
+ version=1,
13
+ box_size=10,
14
+ border=5
15
+ )
16
+ qr.add_data(link)
17
+ qr.make(fit=True)
18
+
19
+ img = qr.make_image(fill_color="black", back_color="white")
20
+
21
+ # Convert to displayable image
22
+ buf = io.BytesIO()
23
+ img.save(buf, format="PNG")
24
+ buf.seek(0)
25
+
26
+ return buf
27
+
28
+ # Gradio UI
29
+ with gr.Blocks(title="Simple QR Code Maker") as demo:
30
+ gr.Markdown("### 🔳 Simple QR Code Maker\nEnter any link to generate a QR code instantly!")
31
+
32
+ link_input = gr.Textbox(label="Enter URL", placeholder="https://example.com")
33
+ output_image = gr.Image(label="Generated QR Code")
34
+
35
+ generate_btn = gr.Button("Generate QR Code")
36
+ generate_btn.click(fn=generate_qr, inputs=link_input, outputs=output_image)
37
+
38
+ demo.launch()