From cbfd7ed7fb8c1bf4aefdcf77aa03d806011daf29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kalevi=20Yyp=C3=A4naho?= Date: Mon, 27 Nov 2023 20:55:03 +0200 Subject: DB_URI and SECRET has now defaults in app.py. Added venv install instructions. --- app.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'app.py') diff --git a/app.py b/app.py index 2f3b965..3d8d5c7 100644 --- a/app.py +++ b/app.py @@ -1,10 +1,20 @@ +from secrets import token_hex from flask import Flask from os import getenv from db_actions import db app = Flask(__name__, static_url_path='') -app.secret_key = getenv("SECRET_KEY") -app.config["SQLALCHEMY_DATABASE_URI"] = getenv("SQLALCHEMY_DATABASE_URI") + +if db_uri := getenv("SQLALCHEMY_DATABASE_URI"): + app.config["SQLALCHEMY_DATABASE_URI"]=db_uri +else: + app.config["SQLALCHEMY_DATABASE_URI"]="postgresql:///" + +if s_key := getenv("SECRET_KEY"): + app.secret_key = s_key +else: + app.secret_key = token_hex() + db.init_app(app) import routes.base -- cgit v1.2.3