mirror of
https://0xacab.org/jvoisin/mat2-web.git
synced 2025-05-12 11:12:17 -04:00
added a docker dev environment
Signed-off-by: Jan Friedli <jan.friedli@immerda.ch>
This commit is contained in:
parent
9d155d171e
commit
06346e1946
8 changed files with 431 additions and 86 deletions
22
utils.py
Normal file
22
utils.py
Normal file
|
@ -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)
|
Loading…
Add table
Add a link
Reference in a new issue