Skip to content

Commit

Permalink
[Dependencies] Bump flask version for jinja2 (#306)
Browse files Browse the repository at this point in the history
* Update flask version to update jinja2

Signed-off-by: Judy Ng <[email protected]>

* Fix deprecated json encoder issues from upgrading flask

Signed-off-by: Judy Ng <[email protected]>

---------

Signed-off-by: Judy Ng <[email protected]>
  • Loading branch information
judysng authored Feb 14, 2024
1 parent 6fc2978 commit 849ea1a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
10 changes: 5 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import datetime

from flask import Response, request
from flask.json import JSONEncoder
from flask.json.provider import DefaultJSONProvider
from werkzeug.routing import BaseConverter

import api.utils as utils
Expand Down Expand Up @@ -56,21 +56,21 @@ def __init__(self, url_map, *items):
self.regex = items[0]


class PClusterJSONEncoder(JSONEncoder):
class PClusterJSONEncoder(DefaultJSONProvider):
"""Make the model objects JSON serializable."""

include_nulls = False

def default(self, obj):
if isinstance(obj, datetime.date):
return utils.to_iso_timestr(obj)
return JSONEncoder.default(self, obj)
return DefaultJSONProvider.default(self, obj)


def run():
app = utils.build_flask_app(__name__)
app.config["APPLICATION_ROOT"] = '/pcui'
app.json_encoder = PClusterJSONEncoder
app.json = PClusterJSONEncoder(app)
app.url_map.converters["regex"] = RegexConverter
CSRF(app, CognitoFingerprintGenerator(CLIENT_ID, CLIENT_SECRET, USER_POOL_ID))

Expand All @@ -79,7 +79,7 @@ def custom_401(_error):
return Response(
"You are not authorized to perform this action.", 401
)

@app.errorhandler(404)
def page_not_found(_error):
return utils.serve_frontend(app)
Expand Down
4 changes: 2 additions & 2 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Flask-Cors==3.0.10
Flask==2.1.2
Flask==2.3.3
Werkzeug==2.3.8
boto3==1.24.30
requests==2.31.0
Expand All @@ -10,4 +10,4 @@ pytest==7.2.2
pytest-mock==3.8.2
itsdangerous==2.1.2
marshmallow==3.19.0
certifi==2023.7.22
certifi==2023.7.22
6 changes: 4 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#
attrs==23.1.0
# via pytest
blinker==1.7.0
# via flask
boto3==1.24.30
# via -r requirements.in
botocore==1.27.96
Expand All @@ -24,7 +26,7 @@ ecdsa==0.18.0
# via python-jose
exceptiongroup==1.1.1
# via pytest
flask==2.1.2
flask==2.3.3
# via
# -r requirements.in
# flask-cors
Expand All @@ -40,7 +42,7 @@ itsdangerous==2.1.2
# via
# -r requirements.in
# flask
jinja2==3.1.2
jinja2==3.1.3
# via flask
jmespath==1.0.1
# via
Expand Down

0 comments on commit 849ea1a

Please sign in to comment.