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()