Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
b6f155a0
Commit
b6f155a0
authored
2 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Fix error_handler
parent
ecb57762
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/__init__.py
+3
-3
3 additions, 3 deletions
app/__init__.py
app/errors/__init__.py
+4
-3
4 additions, 3 deletions
app/errors/__init__.py
app/errors/handlers.py
+2
-7
2 additions, 7 deletions
app/errors/handlers.py
with
9 additions
and
13 deletions
app/__init__.py
+
3
−
3
View file @
b6f155a0
...
@@ -54,6 +54,9 @@ def create_app(config: Config = Config) -> Flask:
...
@@ -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:
...
@@ -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
'
)
...
...
This diff is collapsed.
Click to expand it.
app/errors/__init__.py
+
4
−
3
View file @
b6f155a0
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
handler
s
app
.
register_error_handler
(
HTTPException
,
generic_error_
handler
)
This diff is collapsed.
Click to expand it.
app/errors/handlers.py
+
2
−
7
View file @
b6f155a0
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment