Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
import qrcode
|
|
|
3 |
|
4 |
def url_to_qr(url):
|
5 |
qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=4)
|
6 |
qr.add_data(url)
|
7 |
qr.make(fit=True)
|
8 |
qr_img = qr.make_image(fill_color="black", back_color="white")
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
iface = gr.Interface(fn=url_to_qr, inputs="text", outputs="image")
|
12 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import qrcode
|
3 |
+
import io
|
4 |
|
5 |
def url_to_qr(url):
|
6 |
qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=4)
|
7 |
qr.add_data(url)
|
8 |
qr.make(fit=True)
|
9 |
qr_img = qr.make_image(fill_color="black", back_color="white")
|
10 |
+
|
11 |
+
# Convertir l'image en bytes
|
12 |
+
img_byte_arr = io.BytesIO()
|
13 |
+
qr_img.save(img_byte_arr, format='PNG')
|
14 |
+
img_byte_arr.seek(0)
|
15 |
+
|
16 |
+
return img_byte_arr
|
17 |
|
18 |
iface = gr.Interface(fn=url_to_qr, inputs="text", outputs="image")
|
19 |
iface.launch()
|