Small create_app() re-org
This commit is contained in:
parent
468e232d46
commit
e2be735d3f
|
@ -18,10 +18,7 @@ def create_app(test_config=None) -> Flask:
|
||||||
if not secret_key:
|
if not secret_key:
|
||||||
sys.stderr.write("WARNING: UNDERCOVER_SECRET_KEY is not defined! Application may be insecure.\n")
|
sys.stderr.write("WARNING: UNDERCOVER_SECRET_KEY is not defined! Application may be insecure.\n")
|
||||||
secret_key = "dev"
|
secret_key = "dev"
|
||||||
app.config.from_mapping(
|
app.config.from_mapping(SECRET_KEY=secret_key)
|
||||||
SECRET_KEY=secret_key,
|
|
||||||
# DATABASE=os.path.join(app.instance_path, 'undercover.sqlite'),
|
|
||||||
)
|
|
||||||
|
|
||||||
# if test_config is None:
|
# if test_config is None:
|
||||||
# app.config.from_pyfile('config.py', silent=True)
|
# 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)
|
os.makedirs(app.instance_path, exist_ok=True)
|
||||||
|
|
||||||
|
app.register_blueprint(routes.writing_blueprint)
|
||||||
|
|
||||||
@app.errorhandler(Exception)
|
@app.errorhandler(Exception)
|
||||||
def internal_error(e) -> HTTPException | Response:
|
def internal_error(e) -> HTTPException | Response:
|
||||||
if isinstance(e, HTTPException):
|
if isinstance(e, HTTPException):
|
||||||
|
@ -38,8 +37,6 @@ def create_app(test_config=None) -> Flask:
|
||||||
email.exception_alert(e)
|
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)
|
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)
|
@app.errorhandler(404)
|
||||||
def not_found(e) -> Response:
|
def not_found(e) -> Response:
|
||||||
return make_response(render_template('error.jinja2', status=404, error_text='Page not found!'), 404)
|
return make_response(render_template('error.jinja2', status=404, error_text='Page not found!'), 404)
|
||||||
|
|
Loading…
Reference in New Issue