import gradio as gr FILE = "saved_text.txt" def append_text(text): if text.strip(): with open(FILE, "a") as f: f.write(text + "\n") return f"Appended: {text}" iface = gr.Interface( fn=append_text, inputs=gr.Textbox(lines=5, label="Type here"), outputs="text", title="Append Text to File" ) if __name__ == "__main__": iface.launch()