Skip to content

Commit

Permalink
Use --debug CLI option and debug attribute instead of FLASK_ENV
Browse files Browse the repository at this point in the history
Deprecated in Flask 2.2, see pallets/flask#4714.
Also use --app CLI option instead of FLASK_APP for consistency
  • Loading branch information
pylipp committed Aug 11, 2022
1 parent 6162bbe commit 1864ecf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 1 addition & 5 deletions back/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@ RUN pip install -r requirements.txt && rm requirements.txt
# cf. https://stackoverflow.com/a/60820156/3865876
FROM base AS production
# Launch WSGI server, configured by gunicorn.conf.py
ENV FLASK_ENV production
CMD gunicorn

FROM base AS development
# Path of module containing Flask app, relative to WORKDIR
ENV FLASK_APP boxtribute_server/main
ENV FLASK_ENV development
CMD flask run -h 0.0.0 -p 5000
CMD flask --debug --app boxtribute_server.main run -h 0.0.0 -p 5000

# Select final stage depending on flask_env argument
FROM ${flask_env} AS final
RUN echo Using $FLASK_ENV
6 changes: 3 additions & 3 deletions back/boxtribute_server/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from ariadne import graphql_sync
from ariadne.constants import PLAYGROUND_HTML
from flask import Blueprint, jsonify, request
from flask import Blueprint, current_app, jsonify, request
from flask_cors import cross_origin

from .auth import request_jwt, requires_auth
Expand Down Expand Up @@ -47,7 +47,7 @@ def query_api_server():
query_api_schema,
data=request.get_json(),
context_value=request,
introspection=os.getenv("FLASK_ENV") == "development",
introspection=current_app.debug,
error_formatter=format_database_errors,
)

Expand Down Expand Up @@ -91,7 +91,7 @@ def graphql_server():
data=request.get_json(),
context_value=request,
debug=debug_graphql,
introspection=os.getenv("FLASK_ENV") == "development",
introspection=current_app.debug,
error_formatter=format_database_errors,
)

Expand Down

0 comments on commit 1864ecf

Please sign in to comment.