Quart extension to minify HTML, CSS, JS, and less
Project description
quart_minify
A Quart extension to minify quart response for html, javascript, css and less compilation as well.
Install:
With pip
pip install quart-minify
From the source:
git clone https://github.com/AceFire6/quart_minify.git
cd quart_minify
python setup.py install
Setup:
Inside Quart app:
from quart import Quart
from quart_minify.minify import Minify
app = Quart(__name__)
Minify(app=app)
Result:
Before:
<html>
<head>
<script>
if (true) {
console.log('working !')
}
</script>
<style>
body {
background-color: red;
}
</style>
</head>
<body>
<h1>Example !</h1>
</body>
</html>
After:
<html> <head><script>if(true){console.log('working !')}</script><style>body{background-color:red;}</style></head> <body> <h1>Example !</h1> </body> </html>
Options:
def __init__(self,
app=None,
html=True,
js=False,
cssless=True,
cache=True,
fail_safe=True,
bypass=()):
"""
A Quart extension to minify flask response for html,
javascript, css and less.
@param: app Quart app instance to be passed (default:None).
@param: js To minify the css output (default:False).
@param: cssless To minify spaces in css (default:True).
@param: cache To cache minifed response with hash (default: True).
@param: fail_safe to avoid raising error while minifying (default True).
@param: bypass a list of the routes to be bypassed by the minifier
Notice: bypass route should be identical to the url_rule used for example:
bypass=['/user/<int:user_id>', '/users']
"""
Credit:
Adapted from flask_minify
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
quart-minify-0.2.0.tar.gz
(4.9 kB
view hashes)
Built Distribution
Close
Hashes for quart_minify-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 218ec50fe3a09529c1c0621f6d77dd3d8c7261ea1143995ddb2b18d0795eb400 |
|
MD5 | f006d20e0584bf9b899b8bb159dd201e |
|
BLAKE2b-256 | 2bf2df919e59aaeb7feed9c2ebad9b5600681616710619d94405c65d4e00644a |