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)


@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


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

Uploaded Source

Built Distributions

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

Flask_HTMLmin-2.1.0-py3.7.egg (4.5 kB view details)

Uploaded Egg

Flask_HTMLmin-2.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: Flask-HTMLmin-2.1.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1

File hashes

Hashes for Flask-HTMLmin-2.1.0.tar.gz
Algorithm Hash digest
SHA256 e52815ded22b392a4da6e0ce9308a2d4e25e2c5f97c64fda722a90c343715423
MD5 80eac1b54b1afa45eacfffc5ed17fd8e
BLAKE2b-256 03468d3d331ad33f3835c9ad7b42c3da01d52f1fee0365a01545b5f60b74cd67

See more details on using hashes here.

File details

Details for the file Flask_HTMLmin-2.1.0-py3.7.egg.

File metadata

  • Download URL: Flask_HTMLmin-2.1.0-py3.7.egg
  • Upload date:
  • Size: 4.5 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1

File hashes

Hashes for Flask_HTMLmin-2.1.0-py3.7.egg
Algorithm Hash digest
SHA256 98e1173968517b664a79f5366757b2e71eb424ee0ff5158e23844ca1a0ca801d
MD5 7db40e34b5080f778d3b321ceeeab94a
BLAKE2b-256 754a7c7927b68acc5112ad356d28aecfb41ef73dd4528dc48999b6a6ca563ffe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: Flask_HTMLmin-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1

File hashes

Hashes for Flask_HTMLmin-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50e89c5111aa6d85a445af173ea01a5adc057a2d162d94e9281fcf03dd6ad6bc
MD5 03b7d0c58429ad3a7a554f6b4e5484b4
BLAKE2b-256 016e4b972a26e68c3ffcf9a7fcaae0b2fdbbe8133f5120d1581a5d8895d92bc8

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