random generation of secrets

This commit is contained in:
cellarspoon 2021-12-17 17:37:48 +01:00
parent 00de8a02e9
commit 394e128e9f
No known key found for this signature in database
GPG Key ID: 03789458B3D0C410

12
app.py
View File

@ -1,4 +1,6 @@
import os
import random
import string
from pathlib import Path
import petname
@ -11,9 +13,15 @@ from werkzeug.utils import secure_filename
from wtforms import HiddenField, RadioField, StringField
from wtforms.validators import DataRequired
def rand():
"""Generated random secret."""
return "".join(random.choices(string.ascii_uppercase + string.digits, k=N))
app = Flask(__name__)
app.config["SECRET_KEY"] = "foo"
app.config["WTF_CSRF_SECRET_KEY"] = "bar"
app.config["SECRET_KEY"] = os.environ.get("SECRET_KEY", rand())
app.config["WTF_CSRF_SECRET_KEY"] = os.environ.get("WTF_CSRF_SECRET_KEY", rand())
CWD = Path().resolve()