Spaces:
Runtime error
Runtime error
Commit
·
6a5e75e
1
Parent(s):
de237db
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import qrcode
|
|
|
|
|
3 |
|
4 |
def generate_qr_code(url):
|
5 |
# Create a QR code instance
|
@@ -14,17 +16,21 @@ def generate_qr_code(url):
|
|
14 |
qr.make(fit=True)
|
15 |
# Generate the QR code image
|
16 |
qr_image = qr.make_image(fill_color="black", back_color="white")
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
|
21 |
iface = gr.Interface(
|
22 |
fn=generate_qr_code,
|
23 |
inputs="text",
|
24 |
-
outputs="
|
25 |
title="QR Code Generator",
|
26 |
description="Generate a QR code from a URL",
|
27 |
example="https://www.example.com",
|
28 |
)
|
29 |
|
30 |
-
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import qrcode
|
3 |
+
from PIL import Image
|
4 |
+
from io import BytesIO
|
5 |
|
6 |
def generate_qr_code(url):
|
7 |
# Create a QR code instance
|
|
|
16 |
qr.make(fit=True)
|
17 |
# Generate the QR code image
|
18 |
qr_image = qr.make_image(fill_color="black", back_color="white")
|
19 |
+
|
20 |
+
# Convert PIL image to bytes
|
21 |
+
image_bytes = BytesIO()
|
22 |
+
qr_image.save(image_bytes, format="PNG")
|
23 |
+
image_bytes = image_bytes.getvalue()
|
24 |
+
|
25 |
+
return image_bytes
|
26 |
|
27 |
iface = gr.Interface(
|
28 |
fn=generate_qr_code,
|
29 |
inputs="text",
|
30 |
+
outputs="image",
|
31 |
title="QR Code Generator",
|
32 |
description="Generate a QR code from a URL",
|
33 |
example="https://www.example.com",
|
34 |
)
|
35 |
|
36 |
+
iface.launch()
|