diff --git a/app/__init__.py b/app/__init__.py index 34ded42..48e31a9 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,5 +1,6 @@ from flask import Flask, request, redirect, url_for, render_template from app.views import routes +from flask import jsonify def create_app(): # create and configure the app @@ -7,3 +8,12 @@ def create_app(): app.config.from_pyfile('settings.py') app.register_blueprint(routes) return app + + +@app.errorhandler(403) +def not_authorised(e): + return jsonify(error="Not authorized"), 403 + +@app.errorhandler(500) +def internal_server_error(e): + return jsonify(error="Internal server error"), 500