summaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/utils.py b/utils.py
new file mode 100644
index 0000000..fb2fb08
--- /dev/null
+++ b/utils.py
@@ -0,0 +1,22 @@
1import os
2import hashlib
3
4
5def get_allow_origin_header_value():
6 return os.environ.get('MAT2_ALLOW_ORIGIN_WHITELIST', '*').split(" ")
7
8
9def hash_file(filepath: str) -> str:
10 sha256 = hashlib.sha256()
11 with open(filepath, 'rb') as f:
12 while True:
13 data = f.read(65536) # read the file by chunk of 64k
14 if not data:
15 break
16 sha256.update(data)
17 return sha256.hexdigest()
18
19
20def check_upload_folder(upload_folder):
21 if not os.path.exists(upload_folder):
22 os.mkdir(upload_folder) \ No newline at end of file