Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,21 +7,22 @@ def generate_random_string(length=100):
|
|
| 7 |
"""Generate a random string of fixed length."""
|
| 8 |
return ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(length))
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
os.makedirs(directory)
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
|
| 22 |
with gr.Blocks() as demo:
|
| 23 |
gr.FileExplorer()
|
| 24 |
gr.FileExplorer(root="/data")
|
| 25 |
-
demo.load(create_random_text_files, None, None)
|
| 26 |
|
| 27 |
demo.launch()
|
|
|
|
| 7 |
"""Generate a random string of fixed length."""
|
| 8 |
return ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(length))
|
| 9 |
|
| 10 |
+
directory="/data"
|
| 11 |
+
num_files=10
|
| 12 |
+
file_length=1000
|
|
|
|
| 13 |
|
| 14 |
+
if not os.path.exists(directory):
|
| 15 |
+
os.makedirs(directory)
|
| 16 |
+
|
| 17 |
+
for i in range(num_files):
|
| 18 |
+
file_name = os.path.join(directory, f'random_file_{i}.txt')
|
| 19 |
+
with open(file_name, 'w') as f:
|
| 20 |
+
for _ in range(file_length):
|
| 21 |
+
f.write(generate_random_string() + '\n')
|
| 22 |
|
| 23 |
|
| 24 |
with gr.Blocks() as demo:
|
| 25 |
gr.FileExplorer()
|
| 26 |
gr.FileExplorer(root="/data")
|
|
|
|
| 27 |
|
| 28 |
demo.launch()
|