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:
pip install Flask-HTMLmin
Or use pipenv (recommended):
pipenv install Flask-HTMLmin
Or alternatively, you can download the repository and install 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)
@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
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.0.0.tar.gz
(4.0 kB
view hashes)
Built Distribution
Close
Hashes for Flask_HTMLmin-2.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3169e53b192789b2e0e640cbd2d899f89bfd4d26564cf5c661174b5a1bc163b3 |
|
MD5 | da62ceb51a1ede0074c41eb0e5e18b7f |
|
BLAKE2b-256 | 7e1929b174d41fa129f2ea4336371f145416736387276169b50f9489501447d5 |