ysharma HF Staff commited on
Commit
bf68204
·
verified ·
1 Parent(s): 3bdad20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -8
app.py CHANGED
@@ -1,13 +1,25 @@
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
5
 
6
- with gr.Blocks(theme=gr.themes.Base(radius_size="none")) as demo:
 
 
 
 
7
  with gr.Row():
8
- text1 = gr.Textbox(value="Yuvi")
9
- text2 = gr.Textbox()
10
- btn = gr.Button("GO!")
11
- btn.click(fn=greet, inputs=text1, outputs=text2)
 
 
 
 
 
12
 
13
- demo.launch()
 
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(interactive=False),
7
+ gr.DownloadButton( value=filepath, interactive=True)] #label=f"Download {name}",
8
 
9
+ def download_file():
10
+ return [gr.UploadButton(interactive=True), gr.DownloadButton(interactive=False)]
11
+
12
+ with gr.Blocks(theme=gr.themes.Base(radius_size=gr.themes.sizes.radius_none)) as demo:
13
+ tb = gr.Textbox(value = "First upload a file and and then you'll be able download it (but only once!)")
14
  with gr.Row():
15
+ with gr.Column(scale=1):
16
+ u = gr.UploadButton(icon='icon4.png', elem_classes="hamburger-button", label="", file_count="single")
17
+ with gr.Column(scale=1):
18
+ d = gr.DownloadButton( icon='icon1.png', elem_classes="hamburger-button", label="", interactive=False)
19
+ with gr.Column(scale=1):
20
+ t = gr.Textbox(visible=True, )
21
+
22
+ u.upload(upload_file, u, [u, d])
23
+ d.click(download_file, None, [u, d])
24
 
25
+ demo.launch()