Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ def list_attributes_and_values():
|
|
| 4 |
attr = 'temp_files'
|
| 5 |
value = getattr(fi_output, attr)
|
| 6 |
for tmp in value:
|
| 7 |
-
|
| 8 |
|
| 9 |
def append_text_to_file(text):
|
| 10 |
file_path = 'text_file.txt'
|
|
@@ -13,16 +13,19 @@ def append_text_to_file(text):
|
|
| 13 |
with open(file_path, 'r') as file:
|
| 14 |
new_content = file.read()
|
| 15 |
print(new_content)
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
|
| 19 |
with gr.Blocks() as demo:
|
| 20 |
tb_input = gr.Textbox(label='enter some text')
|
| 21 |
global fi_output
|
| 22 |
-
fi_output = gr.File(type='binary')
|
|
|
|
| 23 |
|
| 24 |
tb_input.submit(append_text_to_file, inputs=tb_input, outputs=fi_output)
|
| 25 |
|
| 26 |
-
fi_output.change(list_attributes_and_values, inputs=None, outputs=
|
| 27 |
|
| 28 |
demo.launch(debug=True)
|
|
|
|
| 4 |
attr = 'temp_files'
|
| 5 |
value = getattr(fi_output, attr)
|
| 6 |
for tmp in value:
|
| 7 |
+
return f"[Click here to download the file](https://organizedprogrammers-test-file-editing.hf.space/file={tmp})"
|
| 8 |
|
| 9 |
def append_text_to_file(text):
|
| 10 |
file_path = 'text_file.txt'
|
|
|
|
| 13 |
with open(file_path, 'r') as file:
|
| 14 |
new_content = file.read()
|
| 15 |
print(new_content)
|
| 16 |
+
with zipfile.ZipFile(zip_file_path, 'w') as zipf:
|
| 17 |
+
zipf.write(file_path, os.path.basename(file_path))
|
| 18 |
+
|
| 19 |
+
return zip_file_path})"
|
| 20 |
|
| 21 |
with gr.Blocks() as demo:
|
| 22 |
tb_input = gr.Textbox(label='enter some text')
|
| 23 |
global fi_output
|
| 24 |
+
fi_output = gr.File(type='binary', visible=False)
|
| 25 |
+
md_hypertext = gr.Markdown()
|
| 26 |
|
| 27 |
tb_input.submit(append_text_to_file, inputs=tb_input, outputs=fi_output)
|
| 28 |
|
| 29 |
+
fi_output.change(list_attributes_and_values, inputs=None, outputs=md_hypertext)
|
| 30 |
|
| 31 |
demo.launch(debug=True)
|