diff --git a/backend/.flaskenv b/backend/.flaskenv index 046b50c..0366019 100644 --- a/backend/.flaskenv +++ b/backend/.flaskenv @@ -1,2 +1,3 @@ FLASK_APP=microblog.py +FLASK_DEBUG=0 diff --git a/backend/app/__init__.py b/backend/app/__init__.py index d57d604..2ea3d48 100644 --- a/backend/app/__init__.py +++ b/backend/app/__init__.py @@ -11,5 +11,5 @@ migrate = Migrate(app, db) login = LoginManager(app) login.login_view = 'login' -from app import routes, models +from app import routes, models, errors diff --git a/backend/app/errors.py b/backend/app/errors.py new file mode 100644 index 0000000..4428603 --- /dev/null +++ b/backend/app/errors.py @@ -0,0 +1,13 @@ +from flask import render_template + +from app import app, db + +@app.errorhandler(404) +def not_found_error(error): + return render_template('404.html'), 404 + +@app.errorhandler(500) +def internal_error(error): + db.session.rollback() + return render_template('500.html'), 500 + diff --git a/backend/app/templates/404.html b/backend/app/templates/404.html new file mode 100644 index 0000000..3c74661 --- /dev/null +++ b/backend/app/templates/404.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} + +{% block content %} + +

File Not Found

+

Back

+ +{% endblock %} diff --git a/backend/app/templates/500.html b/backend/app/templates/500.html new file mode 100644 index 0000000..699d215 --- /dev/null +++ b/backend/app/templates/500.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} + +{% block content %} + +

An unexpected error has occurred.

+

Administrator has been notified.

+

Back

+ +{% endblock %}