summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2021-12-29 20:56:03 +0100
committerHelmut Grohne <helmut@subdivi.de>2021-12-29 20:56:03 +0100
commite118de84d60e6f0d7662dcbb6aa362f452dda6ba (patch)
treecf74481b2ed70291ff3fa190cf053a0798bc51b2
parentc7615fcb537f547da3068d3e489437e70db58447 (diff)
downloaddebian-dedup-e118de84d60e6f0d7662dcbb6aa362f452dda6ba.tar.gz
webapp: improve performance
html_response expects a str-generator, but when we call the render method, we receive a plain str. It can be iterated - one character at a time. That's what encode_and_buffer will do in this case. So better stream all the time.
-rwxr-xr-xwebapp.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/webapp.py b/webapp.py
index 8f5d342..9993cb0 100755
--- a/webapp.py
+++ b/webapp.py
@@ -100,7 +100,7 @@ class Application:
elif endpoint == "index":
if not request.environ["PATH_INFO"]:
raise InternalRedirect("/")
- return html_response(index_template.render(dict(urlroot="")))
+ return html_response(index_template.stream(dict(urlroot="")))
elif endpoint == "source":
return self.show_source(args["package"])
raise NotFound()
@@ -159,7 +159,7 @@ class Application:
(params["pid"],))
params["issues"] = dict(cur.fetchall())
cur.close()
- return html_response(package_template.render(params))
+ return html_response(package_template.stream(params))
def compute_comparison(self, pid1, pid2):
"""Compute a sequence of comparison objects ordered by the size of the
@@ -237,7 +237,7 @@ class Application:
raise NotFound()
params = dict(function=function, hashvalue=hashvalue, entries=entries,
urlroot="../..")
- return html_response(hash_template.render(params))
+ return html_response(hash_template.stream(params))
def show_source(self, package):
with contextlib.closing(self.db.cursor()) as cur:
@@ -256,7 +256,7 @@ class Application:
if not (oldentry and oldentry["savable"] >= size):
binpkgs[binary] = entry
params = dict(source=package, packages=binpkgs, urlroot="..")
- return html_response(source_template.render(params))
+ return html_response(source_template.stream(params))
def main():
parser = argparse.ArgumentParser()