Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,20 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
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 |
-
|
|
|
|
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()
|