Skip to main content

Minify flask text/html mime type responses

Project description

Flask-HTMLmin

PyPI version Supported Python Versions License tests codecov

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


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.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

Flask_HTMLmin-2.2.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file Flask-HTMLmin-2.2.1.tar.gz.

File metadata

  • Download URL: Flask-HTMLmin-2.2.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for Flask-HTMLmin-2.2.1.tar.gz
Algorithm Hash digest
SHA256 b369693600f0297e037233ab4aea3aaea5f7962ed12b988bded458bd89af217a
MD5 b84a70b6849698788afd7b656a259159
BLAKE2b-256 59517cc1ecec6b407b6fcec822b397b5ef60141c87b1072a9adba6b3d8c386e7

See more details on using hashes here.

File details

Details for the file Flask_HTMLmin-2.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for Flask_HTMLmin-2.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dce72b8ee5b777813873704aba1712aad155b7a581de19270d3e9ff333e79cba
MD5 39b774ad1498ebe505bebaddcc8313b8
BLAKE2b-256 3847f0a6b65fe13db1094679d6acf44c24e78d99c12a95958bb7c37dc3b6d786

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page