{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: html_server_functions"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import os\n", "\n", "import gradio as gr\n", "\n", "\n", "def list_files(path):\n", " try:\n", " return os.listdir(path)\n", " except (FileNotFoundError, PermissionError) as e:\n", " return [f\"Error: {e}\"]\n", "\n", "\n", "with gr.Blocks() as demo:\n", " gr.Markdown(\n", " \"# Server Functions Demo\\nClick 'Load Files' to list files in the directory.\"\n", " )\n", " filetree = gr.HTML(\n", " value=os.path.abspath(''),\n", " html_template=\"\"\"\n", "
Directory: ${value}
\n", " \n", " \n", "