Minify flask text/html mime type responses
Project description
Flask-HTMLmin
Minify flask text/html
mime type responses.
Just add MINIFY_HTML = True
to your deployment config to minify HTML and text responses of your flask application.
Installation
To install Flask-HTMLmin, simply use pip:
pip install Flask-HTMLmin
Or use pipenv:
pipenv install Flask-HTMLmin
Or use poetry:
poetry add Flask-HTMLmin
Or alternatively, you can download the repository and install it manually by doing:
git clone git@github.com:hamidfzm/Flask-HTMLmin.git
cd Flask-HTMLmin
python setup.py install
Example
from flask import Flask, render_template
from flask_htmlmin import HTMLMIN
app = Flask(__name__)
app.config['MINIFY_HTML'] = True
htmlmin = HTMLMIN(app)
# or you can use HTMLMIN.init_app(app)
# pass additional parameters to htmlmin
# HTMLMIN(app, **kwargs)
# example:
# htmlmin = HTMLMIN(app, remove_comments=False, remove_empty_space=True, disable_css_min=True)
@app.route('/')
def main():
# index.html will be minimized !!!
return render_template('index.html')
@app.route('/exempt')
@htmlmin.exempt
def exempted_route():
# index.html will be exempted and not blessed by holy htmlmin !!!
return render_template('index.html')
if __name__ == '__main__':
app.run()
TODO
- Test cases
- Route (or URL rule) exemption
- Caching (in progress)
- Minify inline CSS
- Minify inline Javascript
- Type hints
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Flask-HTMLmin-2.2.0.tar.gz
(4.7 kB
view hashes)
Built Distributions
Flask_HTMLmin-2.2.0-py3.7.egg
(6.0 kB
view hashes)
Close
Hashes for Flask_HTMLmin-2.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78cbb4783ca4eb201516b53121b5f673065b5377136e22ba69b16b6733d446f3 |
|
MD5 | 6ea379627447873c848ff7f83cc246d5 |
|
BLAKE2b-256 | e88c3bf24a2f2772875f44b69d80d29bfcdd8348e155e775644f1f9cdd9bc803 |