Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifications for using Flask >=0.11 if available #1550

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions digits/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,19 @@ def handle_error(e):
trace=trace,
), status_code

# Register this handler for all error codes
# Necessary for flask<=0.10.1
for code in HTTP_STATUS_CODES:
if code not in [301]:
app.register_error_handler(code, handle_error)

# Register this handler for all error codes.
# In flask>=0.11 only codes that are defined
# in werkzeug default_exceptions are valid
if str(flask.__version__) >= "0.11":
for code in HTTP_STATUS_CODES:
if code in werkzeug.exceptions.default_exceptions:
app.register_error_handler(code, handle_error)
# Necessary for flask<=0.10.1
else:
for code in HTTP_STATUS_CODES:
if code not in [301]:
app.register_error_handler(code, handle_error)
# File serving


Expand Down
6 changes: 5 additions & 1 deletion digits/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import os

import flask
from flask.ext.socketio import SocketIO
try:
from flask_socketio import SocketIO
except ImportError:
from flask.ext.socketio import SocketIO

from gevent import monkey
monkey.patch_all()

Expand Down