Refactor prettify_or_minify_html_response to comment out minification logic for clarity and maintainability.
This commit is contained in:
parent
2b6d94c766
commit
e5755066c3
1 changed files with 6 additions and 6 deletions
|
@ -14,13 +14,13 @@ def prettify_or_minify_html_response(response):
|
|||
if app.debug:
|
||||
pretty_html = soup.prettify()
|
||||
response.set_data(pretty_html.encode("utf-8")) # type: ignore
|
||||
else:
|
||||
# Minify by stripping extra whitespace between tags and inside text
|
||||
minified_html = re.sub(r">\s+<", "><", str(soup)) # collapse whitespace between tags
|
||||
minified_html = re.sub(r"\s{2,}", " ", minified_html) # collapse multi-spaces to one
|
||||
minified_html = re.sub(r"\n+", "", minified_html) # remove newlines
|
||||
#else:
|
||||
# # Minify by stripping extra whitespace between tags and inside text
|
||||
# minified_html = re.sub(r">\s+<", "><", str(soup)) # collapse whitespace between tags
|
||||
# minified_html = re.sub(r"\s{2,}", " ", minified_html) # collapse multi-spaces to one
|
||||
# minified_html = re.sub(r"\n+", "", minified_html) # remove newlines
|
||||
|
||||
response.set_data(minified_html.encode("utf-8")) # type: ignore
|
||||
# response.set_data(minified_html.encode("utf-8")) # type: ignore
|
||||
|
||||
response.headers['Content-Type'] = 'text/html; charset=utf-8'
|
||||
except Exception as e:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue