mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 19:04:18 +00:00
Fix error_handler
This commit is contained in:
parent
ecb577628b
commit
b6f155a06b
@ -54,6 +54,9 @@ def create_app(config: Config = Config) -> Flask:
|
|||||||
scheduler.init_app(app)
|
scheduler.init_app(app)
|
||||||
socketio.init_app(app, message_queue=app.config['NOPAQUE_SOCKETIO_MESSAGE_QUEUE_URI']) # noqa
|
socketio.init_app(app, message_queue=app.config['NOPAQUE_SOCKETIO_MESSAGE_QUEUE_URI']) # noqa
|
||||||
|
|
||||||
|
from .errors import init_app as init_error_handlers
|
||||||
|
init_error_handlers(app)
|
||||||
|
|
||||||
from .admin import bp as admin_blueprint
|
from .admin import bp as admin_blueprint
|
||||||
app.register_blueprint(admin_blueprint, url_prefix='/admin')
|
app.register_blueprint(admin_blueprint, url_prefix='/admin')
|
||||||
|
|
||||||
@ -69,9 +72,6 @@ def create_app(config: Config = Config) -> Flask:
|
|||||||
from .corpora import bp as corpora_blueprint
|
from .corpora import bp as corpora_blueprint
|
||||||
app.register_blueprint(corpora_blueprint, url_prefix='/corpora')
|
app.register_blueprint(corpora_blueprint, url_prefix='/corpora')
|
||||||
|
|
||||||
from .errors import bp as errors_blueprint
|
|
||||||
app.register_blueprint(errors_blueprint)
|
|
||||||
|
|
||||||
from .jobs import bp as jobs_blueprint
|
from .jobs import bp as jobs_blueprint
|
||||||
app.register_blueprint(jobs_blueprint, url_prefix='/jobs')
|
app.register_blueprint(jobs_blueprint, url_prefix='/jobs')
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from flask import Blueprint
|
from werkzeug.exceptions import HTTPException
|
||||||
|
from .handlers import generic_error_handler
|
||||||
|
|
||||||
|
|
||||||
bp = Blueprint('errors', __name__)
|
def init_app(app):
|
||||||
from . import handlers
|
app.register_error_handler(HTTPException, generic_error_handler)
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
from flask import render_template, request
|
from flask import render_template
|
||||||
from werkzeug.exceptions import HTTPException
|
|
||||||
from . import bp
|
|
||||||
|
|
||||||
|
|
||||||
@bp.errorhandler(HTTPException)
|
|
||||||
def generic_error_handler(e):
|
def generic_error_handler(e):
|
||||||
if (request.accept_mimetypes.accept_json
|
print('test')
|
||||||
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
|
return render_template('errors/error.html.j2', error=e), e.code
|
||||||
|
Loading…
Reference in New Issue
Block a user