Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -14,25 +14,25 @@ def generate_qr(url):
|
|
14 |
qr.make(fit=True)
|
15 |
|
16 |
img = qr.make_image(fill="black", back_color="white")
|
17 |
-
|
18 |
# Save to BytesIO for download
|
19 |
img_io = BytesIO()
|
20 |
img.save(img_io, format="PNG")
|
21 |
img_io.seek(0)
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
# Gradio Interface
|
26 |
-
def qr_interface(url):
|
27 |
-
img, img_io = generate_qr(url)
|
28 |
return img, ("qr_code.png", img_io.getvalue())
|
29 |
|
30 |
iface = gr.Interface(
|
31 |
-
fn=
|
32 |
inputs=gr.Textbox(label="Enter URL"),
|
33 |
-
outputs=[
|
|
|
|
|
|
|
34 |
title="QR Code Generator",
|
35 |
description="Enter a URL to generate and download a QR Code."
|
36 |
)
|
37 |
|
38 |
iface.launch()
|
|
|
|
14 |
qr.make(fit=True)
|
15 |
|
16 |
img = qr.make_image(fill="black", back_color="white")
|
17 |
+
|
18 |
# Save to BytesIO for download
|
19 |
img_io = BytesIO()
|
20 |
img.save(img_io, format="PNG")
|
21 |
img_io.seek(0)
|
22 |
+
|
23 |
+
# Ensure file remains open when accessed
|
|
|
|
|
|
|
|
|
24 |
return img, ("qr_code.png", img_io.getvalue())
|
25 |
|
26 |
iface = gr.Interface(
|
27 |
+
fn=generate_qr,
|
28 |
inputs=gr.Textbox(label="Enter URL"),
|
29 |
+
outputs=[
|
30 |
+
gr.Image(label="Generated QR Code"),
|
31 |
+
gr.File(label="Download QR Code")
|
32 |
+
],
|
33 |
title="QR Code Generator",
|
34 |
description="Enter a URL to generate and download a QR Code."
|
35 |
)
|
36 |
|
37 |
iface.launch()
|
38 |
+
|