auto generate secret_key
This commit is contained in:
parent
9d388cd0c5
commit
dcdf82cade
1
src/config/SECRET_KEY
Normal file
1
src/config/SECRET_KEY
Normal file
@ -0,0 +1 @@
|
||||
b'Dn\xe2\x96\xd9\xe7Z;\xd7;\x03\xbe\xa8J\xc7\xda\xd2\xe6\xfa\xe6HU( '
|
19
src/config/config.py
Normal file
19
src/config/config.py
Normal file
@ -0,0 +1,19 @@
|
||||
import os
|
||||
import random
|
||||
import string
|
||||
|
||||
SECRET_KEY_FILE = './src/config/SECRET_KEY'
|
||||
|
||||
def get_secret_key():
|
||||
if os.path.isfile(SECRET_KEY_FILE):
|
||||
# read the secret key from the file
|
||||
with open(SECRET_KEY_FILE, 'r') as file:
|
||||
secret_key = file.read().strip()
|
||||
return secret_key
|
||||
else:
|
||||
# generate a new secret key
|
||||
secret_key = os.urandom(24)
|
||||
# save it to the file
|
||||
with open(SECRET_KEY_FILE, 'w') as file:
|
||||
file.write(str(secret_key))
|
||||
return secret_key
|
Loading…
Reference in New Issue
Block a user