mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-07-26 14:01:33 +00:00
move blueprints in dedicated folder
This commit is contained in:
app
__init__.py
blueprints
admin
api
auth
contributions
__init__.pyforms.pyroutes.py
spacy_nlp_pipeline_models
tesseract_ocr_pipeline_models
transkribus_htr_pipeline_models
corpora
errors
jobs
main
services
settings
users
workshops
jobs
tasks
5
app/blueprints/errors/__init__.py
Normal file
5
app/blueprints/errors/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from flask import Blueprint
|
||||
|
||||
|
||||
bp = Blueprint('errors', __name__)
|
||||
from . import handlers
|
14
app/blueprints/errors/handlers.py
Normal file
14
app/blueprints/errors/handlers.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from flask import jsonify, render_template, request
|
||||
from werkzeug.exceptions import HTTPException
|
||||
from . import bp
|
||||
|
||||
|
||||
@bp.app_errorhandler(HTTPException)
|
||||
def handle_http_exception(error):
|
||||
''' Generic HTTP exception handler '''
|
||||
accept_json = request.accept_mimetypes.accept_json
|
||||
accept_html = request.accept_mimetypes.accept_html
|
||||
if accept_json and not accept_html:
|
||||
response = jsonify(str(error))
|
||||
return response, error.code
|
||||
return render_template('errors/error.html.j2', error=error), error.code
|
Reference in New Issue
Block a user