Skip to content

Commit

Permalink
Merge pull request #7 from tim-s-ccs/upgrade-flask-to-v2
Browse files Browse the repository at this point in the history
Update to use Flask 2
  • Loading branch information
tim-s-ccs authored Feb 14, 2024
2 parents 6297575 + bf41be9 commit 3858723
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 30 deletions.
16 changes: 8 additions & 8 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ def create_app():

main = Blueprint('main', __name__)

@main.route("/", methods=["GET"])
def index() -> Any:
@main.get("/")
def index() -> str:
return "Hello there"

app.register_blueprint(main)

@app.route("/component/<string:component>", methods=["POST"])
@app.post("/component/<string:component>")
def component(component: str) -> Any:
data = request.json
data: Any = request.get_json()
# Render the component using the data provided
# component is the hyphenated component name e.g. character-count
# data['macro_name'] is the camelcased name e.g. CharacterCount
Expand All @@ -72,15 +72,15 @@ def component(component: str) -> Any:
"""
)

@app.route("/layout/<string:layout>", methods=["POST"])
@app.post("/layout/<string:layout>")
def layout(layout: str) -> Any:
data = request.json
data: Any = request.get_json()
# Render the layout template using the data provided
return render_template(f"digitalmarketplace_frontend_jinja/layouts/{layout}.html", **data.get('params', {}))

@app.route("/error/<string:error>", methods=["POST"])
@app.post("/error/<string:error>")
def error_page(error: str) -> Any:
data = request.json
data: Any = request.get_json()
# Render the error template using the data provided
return render_template(f"digitalmarketplace_frontend_jinja/errors/{error}.html", **data.get('params', {}))

Expand Down
2 changes: 0 additions & 2 deletions requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ mypy
pytest
lxml
flask

types-Jinja2
18 changes: 7 additions & 11 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ccs-digitalmarketplace-apiclient==25.0.0
# via
# -r requirements.txt
# ccs-digitalmarketplace-utils
ccs-digitalmarketplace-utils==64.1.0
ccs-digitalmarketplace-utils==65.0.0
# via
# -r requirements.txt
# ccs-digitalmarketplace-frontend-jinja
Expand Down Expand Up @@ -67,7 +67,7 @@ exceptiongroup==1.2.0
# via pytest
flake8==7.0.0
# via -r requirements-dev.in
flask==1.1.4
flask==2.0.3
# via
# -r requirements-dev.in
# -r requirements.txt
Expand Down Expand Up @@ -110,12 +110,12 @@ idna==3.6
# requests
iniconfig==2.0.0
# via pytest
itsdangerous==1.1.0
itsdangerous==2.1.2
# via
# -r requirements.txt
# flask
# flask-wtf
jinja2==2.11.3
jinja2==3.1.3
# via
# -r requirements.txt
# ccs-digitalmarketplace-frontend-jinja
Expand All @@ -132,10 +132,9 @@ mailchimp3==3.0.21
# via
# -r requirements.txt
# ccs-digitalmarketplace-utils
markupsafe==1.1.1
markupsafe==2.1.4
# via
# -r requirements.txt
# ccs-digitalmarketplace-utils
# jinja2
# wtforms
mccabe==0.7.0
Expand Down Expand Up @@ -205,10 +204,6 @@ tomli==2.0.1
# via
# mypy
# pytest
types-jinja2==2.11.9
# via -r requirements-dev.in
types-markupsafe==1.1.10
# via types-jinja2
typing-extensions==4.9.0
# via mypy
unicodecsv==0.14.1
Expand All @@ -220,9 +215,10 @@ urllib3==1.26.18
# -r requirements.txt
# botocore
# requests
werkzeug==1.0.1
werkzeug==2.0.3
# via
# -r requirements.txt
# ccs-digitalmarketplace-utils
# flask
# flask-login
workdays==1.4
Expand Down
14 changes: 7 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ cachelib==0.10.2
# via flask-session
ccs-digitalmarketplace-apiclient==25.0.0
# via ccs-digitalmarketplace-utils
ccs-digitalmarketplace-utils==64.1.0
ccs-digitalmarketplace-utils==65.0.0
# via ccs-digitalmarketplace-frontend-jinja
certifi==2023.11.17
# via requests
Expand All @@ -36,7 +36,7 @@ defusedxml==0.7.1
# via odfpy
docopt==0.6.2
# via notifications-python-client
flask==1.1.4
flask==2.0.3
# via
# ccs-digitalmarketplace-utils
# flask-gzip
Expand All @@ -59,11 +59,11 @@ govuk-frontend-jinja==2.8.0
# via ccs-digitalmarketplace-frontend-jinja
idna==3.6
# via requests
itsdangerous==1.1.0
itsdangerous==2.1.2
# via
# flask
# flask-wtf
jinja2==2.11.3
jinja2==3.1.3
# via
# ccs-digitalmarketplace-frontend-jinja
# flask
Expand All @@ -74,9 +74,8 @@ jmespath==1.0.1
# botocore
mailchimp3==3.0.21
# via ccs-digitalmarketplace-utils
markupsafe==1.1.1
markupsafe==2.1.4
# via
# ccs-digitalmarketplace-utils
# jinja2
# wtforms
notifications-python-client==8.2.0
Expand Down Expand Up @@ -111,8 +110,9 @@ urllib3==1.26.18
# via
# botocore
# requests
werkzeug==1.0.1
werkzeug==2.0.3
# via
# ccs-digitalmarketplace-utils
# flask
# flask-login
workdays==1.4
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
package_data={'digitalmarketplace_frontend_jinja': components},
include_package_data=True,
install_requires=[
'jinja2<3',
'jinja2>3',
'govuk-frontend-jinja>=2.8.0,<3',
'ccs-digitalmarketplace-utils',
'ccs-digitalmarketplace-utils>=65.0.0',
],
python_requires="~=3.9",
)

0 comments on commit 3858723

Please sign in to comment.