Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
minor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Christian Knuchel
minor
Commits
6fc121d9
Commit
6fc121d9
authored
Jan 27, 2019
by
Fence
🌈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add error handlers
parent
02b910bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
minor/app.py
minor/app.py
+2
-1
minor/error_handlers.py
minor/error_handlers.py
+14
-0
No files found.
minor/app.py
View file @
6fc121d9
from
flask
import
Flask
from
minor.controller
import
ApiController
,
MusicController
from
minor.error_handlers
import
set_error_handlers
class
App
(
object
):
def
__init__
(
self
,
config
):
self
.
_flask
=
Flask
(
__name__
)
self
.
_flask
.
config
[
'MONGODB_SETTINGS'
]
=
{
'db'
:
'minor'
}
self
.
_flask
.
config
.
update
(
config
)
set_error_handlers
(
self
.
_flask
)
from
minor.model
import
db
db
.
init_app
(
self
.
_flask
)
...
...
minor/error_handlers.py
0 → 100644
View file @
6fc121d9
from
flask
import
jsonify
def
set_error_handlers
(
app
):
@
app
.
errorhandler
(
404
)
def
four_o_four
(
e
):
return
jsonify
({
"code"
:
404
,
"msg"
:
"not found"
}),
404
@
app
.
errorhandler
(
500
)
def
five_hundred
(
e
):
return
jsonify
({
"code"
:
500
,
"msg"
:
"internal error"
}),
500
@
app
.
errorhandler
(
403
)
def
verboten
(
e
):
return
jsonify
({
"code"
:
403
,
"msg"
:
"verboten"
}),
403
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment