Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,27 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
def greet(name, intensity):
|
4 |
return "Hello, " + name + "!" * int(intensity)
|
5 |
|
@@ -10,3 +32,4 @@ demo = gr.Interface(
|
|
10 |
)
|
11 |
|
12 |
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(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 |
+
demo.launch()
|
22 |
+
|
23 |
+
|
24 |
+
'''
|
25 |
def greet(name, intensity):
|
26 |
return "Hello, " + name + "!" * int(intensity)
|
27 |
|
|
|
32 |
)
|
33 |
|
34 |
demo.launch()
|
35 |
+
'''
|