/usr/lib/python2.7/dist-packages/flask_htmlmin.py is in python-flask-htmlmin 1.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | from htmlmin import Minifier
__author__ = 'Hamid FzM'
class HTMLMIN(object):
def __init__(self, app=None, **kwargs):
self.app = app
if app is not None:
self.init_app(app)
default_options = {
'remove_comments': True,
'reduce_empty_attributes': True,
'remove_optional_attribute_quotes': False
}
default_options.update(kwargs)
self.html_minify = Minifier(
**default_options)
def init_app(self, app):
app.config.setdefault('MINIFY_PAGE', False)
if app.config['MINIFY_PAGE']:
app.after_request(self.response_minify)
def response_minify(self, response):
"""
minify response html to decrease traffic
"""
if response.content_type == u'text/html; charset=utf-8':
response.direct_passthrough = False
response.set_data(
self.html_minify.minify(response.get_data(as_text=True))
)
return response
return response
|