aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-10-11 10:39:50 +0200
committerWojtek Kosior <koszko@koszko.org>2022-10-11 13:12:15 +0200
commit94e140e685baae38e8977fe90a3304bbc041ae66 (patch)
tree36387f991c6e34eff7eaaf9e1e546b373cca05c4
parent0c8d70daae4c4dfc989edad465db94ffc665416d (diff)
downloadhaketilo-hydrilla-94e140e685baae38e8977fe90a3304bbc041ae66.tar.gz
haketilo-hydrilla-94e140e685baae38e8977fe90a3304bbc041ae66.zip
[server] restore compatibility with flask 1.1
-rw-r--r--setup.cfg6
-rw-r--r--src/hydrilla/server/serve.py11
2 files changed, 12 insertions, 5 deletions
diff --git a/setup.cfg b/setup.cfg
index 8f36393..f21a5b6 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -51,11 +51,11 @@ test = pytest; flask
setup = setuptools_scm; babel
builder = gnupg
-server = flask
-haketilo = flask; itsdangerous; mitmproxy>=8.0,<9; beautifulsoup4[html5lib]
+server = flask>=1.1
+haketilo = flask>=1.1; itsdangerous; mitmproxy>=8.0,<9; beautifulsoup4[html5lib]
SPDX = reuse
-all = reuse; flask; mitmproxy>=8.0,<9; beautifulsoup4[html5lib]; gnupg
+all = reuse; flask>=1.1; mitmproxy>=8.0,<9; beautifulsoup4[html5lib]; gnupg
[options.packages.find]
where = src
diff --git a/src/hydrilla/server/serve.py b/src/hydrilla/server/serve.py
index 7c9789a..00682aa 100644
--- a/src/hydrilla/server/serve.py
+++ b/src/hydrilla/server/serve.py
@@ -141,10 +141,17 @@ def get_resource_or_mapping(item_type: str, identifier: str) \
# no need for send_from_directory(); path is safe, constructed by us
info_path = f'{info.identifier}/{versions.version_string(info.version)}'
file_path = get_malcontent().malcontent_dir_path / item_type / info_path
+
+ if flask.__version__[0:2] in ('0.', '1.'):
+ caching_args = {'add_etags': False, 'cache_timeout': 0}
+ else:
+ caching_args = {'etag': False}
+
return flask.send_file(
str(file_path),
- mimetype = 'application/json',
- etag = False
+ mimetype = 'application/json',
+ conditional = False,
+ **caching_args # type: ignore
)
@bp.route('/mapping/<string:identifier_dot_json>')