Spaces:
Runtime error
Runtime error
import gradio as gr | |
import qrcode | |
import io | |
def url_to_qr(url): | |
qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=4) | |
qr.add_data(url) | |
qr.make(fit=True) | |
qr_img = qr.make_image(fill_color="black", back_color="white") | |
# Convertir l'image en bytes | |
img_byte_arr = io.BytesIO() | |
qr_img.save(img_byte_arr, format='PNG') | |
img_byte_arr.seek(0) | |
return img_byte_arr | |
iface = gr.Interface(fn=url_to_qr, inputs="text", outputs="image") | |
iface.launch() | |