YchKhan's picture
Update app.py
c2b39ba verified
raw
history blame
815 Bytes
import gradio as gr
def list_attributes_and_values(obj):
attr = 'temp_files'
value = getattr(obj, attr)
for tmp in value:
print(f"https://organizedprogrammers-test-file-editing.hf.space/file={tmp}")
def append_text_to_file(text):
file_path = 'text_file.txt'
with open(file_path, 'a') as file:
file.write(text + '\n')
with open(file_path, 'r') as file:
new_content = file.read()
print(new_content)
return file_path
with gr.Blocks() as demo:
tb_input = gr.Textbox(label='enter some text')
global fi_output
fi_output = gr.File(type='binary')
tb_input.submit(append_text_to_file, inputs=tb_input, outputs=fi_output)
fi_output.change(list_attributes_and_values, inputs=fi_output, outputs=None)
demo.launch(debug=True)