Skip to main content

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

Metadata

Release files for Flask-HTMLmin 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Flask-HTMLmin 3.0.0
File Size Uploaded
flask_htmlmin-3.0.0.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Flask-HTMLmin 3.0.0
File Interpreter ABI Platform
Flask_HTMLmin-3.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.5 kB

Release files / flask_htmlmin-3.0.0.tar.gz

Download URL flask_htmlmin-3.0.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d34300a68b6fe0b3b418412aabe77956065ff6be75b3faa3394ea2847749389a
BLAKE2b-256 checksum
How to use checksums
f0ff259c7f1b8d03ac210fe2cb3f6ffb83b34445772e8e06fa255286861fa220
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.9.21

Release files / Flask_HTMLmin-3.0.0-py3-none-any.whl

Download URL Flask_HTMLmin-3.0.0-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30dcee47754b90d9bddb1ff351e170998e1521f190f60267f03a37b0679acd10
BLAKE2b-256 checksum
How to use checksums
56b9a16b3a0b22b7402ff9bfdf841c9351fe85e0866dd660c136a9cb71fcefa5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.9.21

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 release files

2.2.1

2 release files

2.2.0

3 release files

2.1.0

3 release files

2.0.3

3 release files

2.0.0

2 release files

1.5.2

3 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.2

2 release files

1.3.1

1 release file

1.3.0

1 release file

1.2.1

1 release file

1.2

1 release file

1.1

1 release file

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page