abidlabs HF Staff commited on
Commit
f6c37ea
·
1 Parent(s): c4d5f21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
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
- def create_random_text_files(directory="/data", num_files=10, file_length=1000):
11
- """Create specified number of random text files with random content."""
12
- if not os.path.exists(directory):
13
- os.makedirs(directory)
14
 
15
- for i in range(num_files):
16
- file_name = os.path.join(directory, f'random_file_{i}.txt')
17
- with open(file_name, 'w') as f:
18
- for _ in range(file_length):
19
- f.write(generate_random_string() + '\n')
 
 
 
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()