File size: 740 Bytes
0c6517e
1d749da
 
 
 
 
 
 
 
 
 
 
0c47685
1d749da
 
 
0c6517e
e979e0d
1d749da
e979e0d
1d749da
0c47685
1d749da
 
0c6517e
23b62b8
0c6517e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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))
        print(file_list)
        return "\n".join(file_list)
    except Exception as e:
        return f"Error: {str(e)}"

# Define the Gradio interface
iface = gr.Interface(
    fn=list_files_and_folders,
    inputs=None,
    outputs=gr.Textbox("ready"),
    title="List Files and Folders in Current Directory"
)

# Launch the Gradio interface
iface.launch()