import os import gradio as gr # Path to the directory containing HTML files html_files_path = "html_files" html_files = [f for f in os.listdir(html_files_path) if f.endswith('.html')] def show_html(file_name): with open(os.path.join(html_files_path, file_name), 'r', encoding='utf-8') as file: return file.read() # Create a dropdown to select an HTML file file_dropdown = gr.Dropdown(label="Select an HTML file", choices=html_files, value=html_files[0]) # Create an HTML component to display the selected HTML file's content html_output = gr.HTML() # Interface iface = gr.Interface(fn=show_html, inputs=file_dropdown, outputs=html_output, title="HTML File Viewer", description="Select an HTML file to view its content.") if __name__ == "__main__": iface.launch()