Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,41 @@ import requests
|
|
| 3 |
import csv
|
| 4 |
from io import StringIO
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# Required NetFlow schema
|
| 7 |
required_columns = [
|
| 8 |
'Flow duration', 'Source port', 'Destination port',
|
|
|
|
| 3 |
import csv
|
| 4 |
from io import StringIO
|
| 5 |
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
import os
|
| 9 |
+
import random
|
| 10 |
+
import string
|
| 11 |
+
|
| 12 |
+
# Function to generate random file content
|
| 13 |
+
def generate_random_content(size=100):
|
| 14 |
+
return ''.join(random.choices(string.ascii_letters + string.digits + string.punctuation, k=size))
|
| 15 |
+
|
| 16 |
+
# Create a new folder
|
| 17 |
+
folder_name = "random_files_folder"
|
| 18 |
+
os.makedirs(folder_name, exist_ok=True)
|
| 19 |
+
print(f"Folder '{folder_name}' created.")
|
| 20 |
+
|
| 21 |
+
# Generate random files
|
| 22 |
+
num_files = 5 # Number of random files to create
|
| 23 |
+
for i in range(num_files):
|
| 24 |
+
# Random file name
|
| 25 |
+
file_name = ''.join(random.choices(string.ascii_lowercase, k=8)) + ".txt"
|
| 26 |
+
file_path = os.path.join(folder_name, file_name)
|
| 27 |
+
|
| 28 |
+
# Random content for each file
|
| 29 |
+
content = generate_random_content(size=random.randint(50, 200)) # Random content length between 50 and 200 characters
|
| 30 |
+
|
| 31 |
+
# Write the content to the file
|
| 32 |
+
with open(file_path, 'w') as file:
|
| 33 |
+
file.write(content)
|
| 34 |
+
|
| 35 |
+
print(f"Created file: {file_path}")
|
| 36 |
+
|
| 37 |
+
print("All random files generated successfully.")
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
# Required NetFlow schema
|
| 42 |
required_columns = [
|
| 43 |
'Flow duration', 'Source port', 'Destination port',
|