Skip to main content

Compress and minify Flask responses!

Project description

Flask-Squeeze

Downloads Downloads Downloads

Flask-Squeeze is a Flask extension that automatically:

  • Minifies JS and CSS responses.
  • Compresses all HTTP responses with brotli.
  • Caches static files so that they don't have to be re-compressed. The cache will be cleared each time Flask restarts! Files are considered to be static if they are contained in a directory that is named "static" (Or generally, if they contain "/static/" in their request path.

Installation

pip3 install Flask-Squeeze

Usage

from flask_squeeze import Squeeze
squeeze = Squeeze()

# Initialize Extension
squeeze.init_app(app)

Thats all!

Options

You can configure Flask-Squeeze with the following options in your Flask config:

  • COMPRESS_FLAG (default=True): Globally enables or disables Flask-Squeeze

  • COMPRESS_MIN_SIZE (default=500): Defines the minimum file size in bytes to activate the brotli compression

  • COMPRESS_LEVEL_STATIC (default=11): Possible value are 0 (lowest) to 11 (highest). Defines the compression level of brotli for files in static folders. Theses files fill also be cached, so that they only have to be compressed once.

  • COMPRESS_LEVEL_DYNAMIC (default=5): Possible value are 0 (lowest) to 11 (highest). Defines the compression level of brotli for dynamic files like generated HTML files. Theses files will not be cached, so they will be compressed for each response.

  • COMPRESS_MINIFY_CSS (default=True): Enable or disable css minification using rcssmin.

  • COMPRESS_MINIFY_JS (default=True): Enable or disable css minification using rcssmin.

  • COMPRESS_VERBOSE_LOGGING (default=False): Enable or disable verbose logging. If enabled, Flask-Squeeze will print what it does into the terminal in a highlighted color.

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-squeeze-1.13.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

flask_squeeze-1.13.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file flask-squeeze-1.13.0.tar.gz.

File metadata

  • Download URL: flask-squeeze-1.13.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.1 Darwin/21.3.0

File hashes

Hashes for flask-squeeze-1.13.0.tar.gz
Algorithm Hash digest
SHA256 1cfc974480d94453ac8a6c1ff0b75f6ee823c0475139d2273a9737a11017737c
MD5 cac5f714c71945635d6398299b25c4a6
BLAKE2b-256 e156cd0c8d3bec9362ab1ffdd230fa7da77bcef30f6e8ed12868a99aa37f6d45

See more details on using hashes here.

File details

Details for the file flask_squeeze-1.13.0-py3-none-any.whl.

File metadata

  • Download URL: flask_squeeze-1.13.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.1 Darwin/21.3.0

File hashes

Hashes for flask_squeeze-1.13.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0aab438c649de546af1d3d68f40d8cf2a3399a7d59ce370d5fbbeaa3b0ad29c
MD5 3508d0f53eba43ce37e924ddba567bcd
BLAKE2b-256 fffbd13878e5cf09ae19072ede32ae8c6f5bf9c79c44b395f55364c0cc6bf9af

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