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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Flask_HTMLmin-3.0.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file flask_htmlmin-3.0.0.tar.gz.

File metadata

  • Download URL: flask_htmlmin-3.0.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for flask_htmlmin-3.0.0.tar.gz
Algorithm Hash digest
SHA256 d34300a68b6fe0b3b418412aabe77956065ff6be75b3faa3394ea2847749389a
MD5 be775efe4f5570841d71331f4de3d9eb
BLAKE2b-256 f0ff259c7f1b8d03ac210fe2cb3f6ffb83b34445772e8e06fa255286861fa220

See more details on using hashes here.

File details

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

File metadata

  • Download URL: Flask_HTMLmin-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for Flask_HTMLmin-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 30dcee47754b90d9bddb1ff351e170998e1521f190f60267f03a37b0679acd10
MD5 223c1b2f04c9a99fff2e0386ffbde33e
BLAKE2b-256 56b9a16b3a0b22b7402ff9bfdf841c9351fe85e0866dd660c136a9cb71fcefa5

See more details on using hashes here.

Supported by

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