Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,26 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
def
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
| 9 |
|
| 10 |
-
# Interfaz Blocks
|
| 11 |
with gr.Blocks() as demo:
|
| 12 |
-
gr.Markdown("## 馃摜
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
download_btn.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
if __name__ == "__main__":
|
| 19 |
demo.launch()
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import io
|
| 3 |
|
| 4 |
+
# Genera un BytesIO con el texto y retorna (BytesIO, nombre)
|
| 5 |
+
def return_bytesio(text):
|
| 6 |
+
file_bytes = io.BytesIO()
|
| 7 |
+
file_bytes.write(text.encode("utf-8"))
|
| 8 |
+
file_bytes.seek(0)
|
| 9 |
+
return (file_bytes, "output.txt")
|
| 10 |
|
|
|
|
| 11 |
with gr.Blocks() as demo:
|
| 12 |
+
gr.Markdown("## 馃摜 Simple Download Demo")
|
| 13 |
+
|
| 14 |
+
text_input = gr.Textbox(label="Escribe una palabra", placeholder="Ingresa algo...")
|
| 15 |
+
file_output = gr.File(label="Descargar Archivo")
|
| 16 |
+
download_btn = gr.Button("Generar & Descargar")
|
| 17 |
+
|
| 18 |
+
download_btn.click(
|
| 19 |
+
return_bytesio,
|
| 20 |
+
inputs=text_input,
|
| 21 |
+
outputs=file_output,
|
| 22 |
+
)
|
| 23 |
|
| 24 |
if __name__ == "__main__":
|
| 25 |
demo.launch()
|
| 26 |
+
|