import os
import gradio as gr
def list_files(path):
try:
return os.listdir(path)
except (FileNotFoundError, PermissionError) as e:
return [f"Error: {e}"]
with gr.Blocks() as demo:
gr.Markdown(
"# Server Functions Demo\nClick 'Load Files' to list files in the directory."
)
filetree = gr.HTML(
value=os.path.dirname(__file__),
html_template="""