wasmdashai commited on
Commit
7d54bec
·
verified ·
1 Parent(s): c868f53

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -14
app.py CHANGED
@@ -1,17 +1,20 @@
1
- import gradio as gr
 
 
 
 
 
 
 
 
 
2
 
3
- def download_file(file_path):
4
- filename=f"/dowload_file/ccc.txt"
5
- with open(filename, 'w') as f:
6
- f.write("This is a sample file created by Gradio.")
7
- return filename
8
-
9
- interface = gr.Interface(
10
- fn=download_file,
11
- inputs=gr.File(label="Select file to download"),
12
- outputs=gr.Label("dd"),
13
- title="Download File",
14
- description="Select a file from your computer to download."
15
  )
16
 
17
- interface.launch(share=True)
 
 
1
+ def save_file(file):
2
+ # Get the file name
3
+ file_name = file.name
4
+
5
+ # Save the file to the specified folder
6
+ file_path = os.path.join(upload_folder, file_name)
7
+ with open(file_path, "wb") as f:
8
+ f.write(file.read())
9
+
10
+ return f"File saved to: {file_path}"
11
 
12
+ # Create the Gradio interface
13
+ iface = gr.Interface(
14
+ fn=save_file, # The function to handle file saving
15
+ inputs=gr.inputs.File(), # Input widget to upload a file
16
+ outputs="text" # Output: confirmation message with file path
 
 
 
 
 
 
 
17
  )
18
 
19
+ # Launch the app
20
+ iface.launch()