Skip to content

Commit

Permalink
Fix compatibility with werkzeug 2.1.x
Browse files Browse the repository at this point in the history
Update the code for werkzeug 2.1.x where `BaseResponse` class was
replaced by `Response`.

See: pallets/werkzeug#2276

Taken from postmanlabs#684
  • Loading branch information
mgorny committed Aug 1, 2023
1 parent cefb0c4 commit 496d0b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions httpbin/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
)
from werkzeug.datastructures import WWWAuthenticate, MultiDict
from werkzeug.http import http_date
from werkzeug.wrappers import BaseResponse
try:
from werkzeug.wrappers import Response
except ImportError: # werkzeug < 2.1
from werkzeug.wrappers import BaseResponse as Response
from werkzeug.http import parse_authorization_header
from flasgger import Swagger, NO_SANITIZER

Expand Down Expand Up @@ -76,7 +79,7 @@ def jsonify(*args, **kwargs):


# Prevent WSGI from correcting the casing of the Location header
BaseResponse.autocorrect_location_header = False
Response.autocorrect_location_header = False

# Find the correct template folder when running from a different location
tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "templates")
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
packages=find_packages(),
include_package_data = True, # include files listed in MANIFEST.in
install_requires=[
'Flask<2', 'MarkupSafe<2.1', 'decorator', 'itsdangerous<2.1', 'brotlipy',
'raven[flask]', 'werkzeug<2', 'gevent', 'flasgger', 'jinja2<3.1'
'Flask<2.3', 'MarkupSafe', 'decorator', 'itsdangerous', 'brotlipy',
'raven[flask]', 'werkzeug<2.3', 'gevent', 'flasgger', 'jinja2'
],
)

0 comments on commit 496d0b9

Please sign in to comment.