Rahatara commited on
Commit
d3fcf88
·
verified ·
1 Parent(s): 5ab01cd

Create app.py

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