Load secret key in app

This commit is contained in:
Tim Van Baak 2020-01-03 17:06:18 -08:00
parent ed106cf787
commit 0501b62c8b
2 changed files with 12 additions and 3 deletions

View File

@ -1,6 +1,9 @@
from flask import Flask, render_template
app = Flask(__name__)
import config
app = Flask("amanuensis")
app.secret_key = bytes.fromhex(config.get('secret_key'))
@app.route("/")
def root():

View File

@ -109,8 +109,14 @@ def command_generate_secret(args):
@add_argument("-p", "--port", default="5000")
def command_run(args):
"""Runs the default Flask development server"""
from app import app
app.run(host=args.address, port=args.port)
import app
import config
if config.get("secret_key") is None:
config.logger.error("Can't run server without a secret_key. Run generate-secret first")
return -1
app.app.run(host=args.address, port=args.port)
@add_argument("--foo", action="store_true")
def command_dump(args):