File size: 506 Bytes
d516a37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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()