From 06346e19464c376c0c2ca13ef4218559f9df4212 Mon Sep 17 00:00:00 2001 From: JF Date: Tue, 9 Jul 2019 14:56:21 -0700 Subject: added a docker dev environment Signed-off-by: Jan Friedli --- utils.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 utils.py (limited to 'utils.py') diff --git a/utils.py b/utils.py new file mode 100644 index 0000000..fb2fb08 --- /dev/null +++ b/utils.py @@ -0,0 +1,22 @@ +import os +import hashlib + + +def get_allow_origin_header_value(): + return os.environ.get('MAT2_ALLOW_ORIGIN_WHITELIST', '*').split(" ") + + +def hash_file(filepath: str) -> str: + sha256 = hashlib.sha256() + with open(filepath, 'rb') as f: + while True: + data = f.read(65536) # read the file by chunk of 64k + if not data: + break + sha256.update(data) + return sha256.hexdigest() + + +def check_upload_folder(upload_folder): + if not os.path.exists(upload_folder): + os.mkdir(upload_folder) \ No newline at end of file -- cgit v1.3