Daniela-C commited on
Commit
8ebed02
1 Parent(s): 4e8920b

Update Upload_file

Browse files
Files changed (1) hide show
  1. Upload_file +21 -6
Upload_file CHANGED
@@ -1,7 +1,22 @@
1
- import streamlit as st
 
2
 
3
- uploaded_files = st.file_uploader("Choose a CSV file", accept_multiple_files=True)
4
- for uploaded_file in uploaded_files:
5
- bytes_data = uploaded_file.read()
6
- st.write("filename:", uploaded_file.name)
7
- st.write(bytes_data)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ import gradio as gr
3
 
4
+ def upload_file(filepath):
5
+ name = Path(filepath).name
6
+ return [gr.UploadButton(visible=False), gr.DownloadButton(label=f"Download {name}", value=filepath, visible=True)]
7
+
8
+ def download_file():
9
+ return [gr.UploadButton(visible=True), gr.DownloadButton(visible=False)]
10
+
11
+ with gr.Blocks() as demo:
12
+ gr.Markdown("First upload a file and and then you'll be able download it (but only once!)")
13
+ with gr.Row():
14
+ u = gr.UploadButton("Upload a file", file_count="single")
15
+ d = gr.DownloadButton("Download the file", visible=False)
16
+
17
+ u.upload(upload_file, u, [u, d])
18
+ d.click(download_file, None, [u, d])
19
+
20
+
21
+ if __name__ == "__main__":
22
+ demo.launch()