diff options
author | Kalevi Yypänaho <kyypanah@local> | 2023-11-27 20:55:03 +0200 |
---|---|---|
committer | Kalevi Yypänaho <kyypanah@local> | 2023-11-27 20:55:03 +0200 |
commit | cbfd7ed7fb8c1bf4aefdcf77aa03d806011daf29 (patch) | |
tree | 20f668b774f643e1b472f5b8753c18aba301a81d /app.py | |
parent | d74aca91c689b54b7b49bbfa7121f458f4caf751 (diff) |
DB_URI and SECRET has now defaults in app.py. Added venv install instructions.
Diffstat (limited to 'app.py')
-rw-r--r-- | app.py | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -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 |