Skip to content

Commit 880df55

Browse files
author
Marc-André Rivet
committed
Apply COMPRESS_ALGORITHM if not already overriden
1 parent 32a6e42 commit 880df55

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Diff for: dash/dash.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -284,16 +284,19 @@ def __init__(
284284
elif isinstance(server, bool):
285285
name = name if name else "__main__"
286286
self.server = flask.Flask(name) if server else None
287-
if self.server is not None and _flask_compress_version >= parse_version(
288-
"1.6.0"
289-
):
290-
# flask-compress==1.6.0 changed default to ['br', 'gzip']
291-
# and non-overridable default compression with Brotli is
292-
# causing performance issues
293-
self.server.config["COMPRESS_ALGORITHM"] = ["gzip"]
294287
else:
295288
raise ValueError("server must be a Flask app or a boolean")
296289

290+
if (
291+
self.server is not None
292+
and not hasattr(self.server.config, "COMPRESS_ALGORITHM")
293+
and _flask_compress_version >= parse_version("1.6.0")
294+
):
295+
# flask-compress==1.6.0 changed default to ['br', 'gzip']
296+
# and non-overridable default compression with Brotli is
297+
# causing performance issues
298+
self.server.config["COMPRESS_ALGORITHM"] = ["gzip"]
299+
297300
base_prefix, routes_prefix, requests_prefix = pathname_configs(
298301
url_base_pathname, routes_pathname_prefix, requests_pathname_prefix
299302
)

0 commit comments

Comments
 (0)