import gradio as gr # Function to generate a file for download def generate_file(): file_path = "example_file.txt" # Create the file with open(file_path, "w") as file: file.write("This is a downloadable file.") return file_path # Create a Gradio interface to download the file interface = gr.Interface( fn=generate_file, inputs=None, outputs=gr.File(label="Download the file"), title="Download File Example" ) # Launch the Gradio app interface.launch()