from flask import render_template, request from werkzeug.exceptions import HTTPException from . import bp @bp.errorhandler(HTTPException) def generic_error_handler(e): if (request.accept_mimetypes.accept_json and not request.accept_mimetypes.accept_html): return {'errors': {'message': e.description}}, e.code return render_template('errors/error.html.j2', error=e), e.code