/
View dependency graph
Depends on
- cssmin (python3-cssmin)
- dh-python (dh-sequence-python3, pybuild-plugin-pyproject)
- flask (python3-flask)
- htmlmin (python3-htmlmin)
- pytest (python3-pytest)
- python3-defaults (python3-all)
- setuptools (python3-setuptools)
- debhelper-compat
README (full)
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 [email protected]: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
| dir | .github/ |
| dir | debian/ |
| dir | flask_htmlmin/ |
| file | .gitignore |
| file | LICENSE |
| file | MANIFEST.in |
| file | Pipfile |
| file | Pipfile.lock |
| file | README.md |
| file | SECURITY.md |
| file | setup.cfg |
| file | setup.py |
| file | test.py |