Spaces:
Runtime error
Runtime error
File size: 679 Bytes
a7296a8 91007b3 64c71e5 91007b3 994c145 8c65fc6 91007b3 8c65fc6 c41174e 6f83781 91007b3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import gradio as gr
import io
# Genera un BytesIO con el texto y retorna (BytesIO, nombre)
def return_bytesio(text):
file_bytes = io.BytesIO()
file_bytes.write(text.encode("utf-8"))
file_bytes.seek(0)
return (file_bytes, "output.txt")
with gr.Blocks() as demo:
gr.Markdown("## 📥 Simple Download Demo")
text_input = gr.Textbox(label="Escribe una palabra", placeholder="Ingresa algo...")
file_output = gr.File(label="Descargar Archivo")
download_btn = gr.Button("Generar & Descargar")
download_btn.click(
return_bytesio,
inputs=text_input,
outputs=file_output,
)
if __name__ == "__main__":
demo.launch()
|