Prathmesh48 commited on
Commit
1d749da
1 Parent(s): 0c6517e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -4
app.py CHANGED
@@ -1,8 +1,24 @@
1
- import os
2
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- def print_cwd():
5
- return os.getcwd()
 
 
 
 
6
 
7
- iface = gr.Interface(fn=print_cwd, inputs=[], outputs="text")
8
  iface.launch()
 
 
1
  import gradio as gr
2
+ import os
3
+
4
+ def list_files_and_folders():
5
+ try:
6
+ cwd = os.getcwd() # Get the current working directory
7
+ file_list = []
8
+ for root, dirs, files in os.walk(cwd):
9
+ for file in files:
10
+ file_list.append(os.path.join(root, file))
11
+ for dir in dirs:
12
+ file_list.append(os.path.join(root, dir))
13
+ return "\n".join(file_list)
14
+ except Exception as e:
15
+ return f"Error: {str(e)}"
16
 
17
+ iface = gr.Interface(
18
+ fn=list_files_and_folders,
19
+ inputs=None,
20
+ outputs=gr.outputs.Textbox(label="Files and folders in current directory"),
21
+ title="List Files and Folders in Current Directory"
22
+ )
23
 
 
24
  iface.launch()