Small create_app() re-org

This commit is contained in:
Sage Vaillancourt 2022-10-02 16:25:23 -04:00
parent 468e232d46
commit e2be735d3f
1 changed files with 3 additions and 6 deletions

View File

@ -18,10 +18,7 @@ def create_app(test_config=None) -> Flask:
if not secret_key:
sys.stderr.write("WARNING: UNDERCOVER_SECRET_KEY is not defined! Application may be insecure.\n")
secret_key = "dev"
app.config.from_mapping(
SECRET_KEY=secret_key,
# DATABASE=os.path.join(app.instance_path, 'undercover.sqlite'),
)
app.config.from_mapping(SECRET_KEY=secret_key)
# if test_config is None:
# app.config.from_pyfile('config.py', silent=True)
@ -30,6 +27,8 @@ def create_app(test_config=None) -> Flask:
os.makedirs(app.instance_path, exist_ok=True)
app.register_blueprint(routes.writing_blueprint)
@app.errorhandler(Exception)
def internal_error(e) -> HTTPException | Response:
if isinstance(e, HTTPException):
@ -38,8 +37,6 @@ def create_app(test_config=None) -> Flask:
email.exception_alert(e)
return make_response(render_template('error.jinja2', status=500, error_text='Internal error occurred.', extra_text="We're looking into it!"), 500)
app.register_blueprint(routes.writing_blueprint)
@app.errorhandler(404)
def not_found(e) -> Response:
return make_response(render_template('error.jinja2', status=404, error_text='Page not found!'), 404)