exceptions

This commit is contained in:
Matthew Frost 2023-11-19 01:48:18 +01:00
parent 765d56ecc7
commit 4ff2a93cb9

View file

@ -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