Prathmesh48's picture
Update app.py
23b62b8 verified
raw
history blame
877 Bytes
import gradio as gr
import os
def list_files_and_folders():
try:
cwd = os.getcwd() # Get the current working directory
file_list = []
for root, dirs, files in os.walk(cwd):
for file in files:
file_list.append(os.path.join(root, file))
for dir in dirs:
file_list.append(os.path.join(root, dir))
return "\n".join(file_list)
except Exception as e:
return f"Error: {str(e)}"
# Display the current working directory's contents
output_text = list_files_and_folders()
# Define the Gradio interface to display the output text
iface = gr.Interface(
fn=lambda: output_text,
inputs=None,
outputs=gr.outputs.Textbox(label="Files and folders in current directory"),
title="List Files and Folders in Current Directory"
)
# Launch the Gradio interface
iface.launch()