|
import gradio as gr |
|
import os |
|
|
|
|
|
def upload_files(files): |
|
file_paths = [] |
|
for file in files: |
|
file_paths.append(file.name) |
|
return file_paths |
|
|
|
|
|
def display_files(file_paths): |
|
if not file_paths: |
|
return "Nenhum arquivo enviado ainda." |
|
file_list = "<ul>" |
|
for path in file_paths: |
|
file_name = os.path.basename(path) |
|
file_list += f'<li><a href="{path}" download="{file_name}">{file_name}</a></li>' |
|
file_list += "</ul>" |
|
return file_list |
|
|
|
|
|
with gr.Blocks() as demo: |
|
with gr.Row(): |
|
with gr.Column(): |
|
file_input = gr.File(label="Envie seus arquivos", file_count="multiple") |
|
upload_button = gr.Button("Enviar") |
|
with gr.Column(): |
|
file_output = gr.HTML(label="Arquivos Disponíveis para Download") |
|
|
|
upload_button.click(fn=upload_files, inputs=file_input, outputs=file_output) |
|
file_input.change(fn=display_files, inputs=file_input, outputs=file_output) |
|
|
|
demo.launch() |