Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -66,11 +66,13 @@ def upload_file(file, username):
|
|
66 |
return "Please log in to upload files."
|
67 |
|
68 |
# Save the uploaded file
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
74 |
|
75 |
# Function to retrieve the list of users
|
76 |
def get_users():
|
@@ -110,5 +112,5 @@ with gr.Blocks() as demo:
|
|
110 |
upload_output = gr.Textbox(label="Output", interactive=False)
|
111 |
upload_btn.click(upload_file, inputs=[upload_file_input, username_upload], outputs=upload_output)
|
112 |
|
113 |
-
# Launch the Gradio app
|
114 |
-
demo.launch()
|
|
|
66 |
return "Please log in to upload files."
|
67 |
|
68 |
# Save the uploaded file
|
69 |
+
if isinstance(file, str): # Check if it's a filename string
|
70 |
+
file_path = os.path.join(UPLOAD_FOLDER, file)
|
71 |
+
with open(file_path, "wb") as f:
|
72 |
+
f.write(file) # Write the file data
|
73 |
+
return f"File '{file}' uploaded successfully by {decoded_username}."
|
74 |
+
else:
|
75 |
+
return "Invalid file format."
|
76 |
|
77 |
# Function to retrieve the list of users
|
78 |
def get_users():
|
|
|
112 |
upload_output = gr.Textbox(label="Output", interactive=False)
|
113 |
upload_btn.click(upload_file, inputs=[upload_file_input, username_upload], outputs=upload_output)
|
114 |
|
115 |
+
# Launch the Gradio app with public link
|
116 |
+
demo.launch(share=True)
|