import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SECRETS_DIR = os.path.join(BASE_DIR,'server_secrets') SKB = os.path.join(SECRETS_DIR,'SECRET_KEY.bin') DBG = os.path.join(SECRETS_DIR,'DEBUG.txt') if not os.path.exists(SECRETS_DIR): os.makedirs(SECRETS_DIR) if not os.path.exists(SKB): with open(SKB,'wb') as f: f.write(os.urandom(512)) if not os.path.exists(DBG): with open(DBG,'wt') as f: f.write('False') def isTrue(s: str) -> bool: return s in ['1','true','t','True','TRUE','yes','y','YES','Yes'] SECRET_KEY = None DEBUG = None with open(SKB,'rb') as f: SECRET_KEY = f.read() with open(DBG,'rt') as f: DEBUG = isTrue(f.read().strip())