A Quart extension to minify quart response for html, javascript, css and less compilation as well.
pip install quart-minify
git clone https://github.com/AceFire6/quart_minify.git
cd quart_minify
python setup.py install
from quart import Quart
from quart_minify.minify import Minify
app = Quart(__name__)
Minify(app=app)
<html>
<head>
<script>
if (true) {
console.log('working !')
}
</script>
<style>
body {
background-color: red;
}
</style>
</head>
<body>
<h1>Example !</h1>
</body>
</html>
<html> <head><script>if(true){console.log('working !')}</script><style>body{background-color:red;}</style></head> <body> <h1>Example !</h1> </body> </html>
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']
"""
Adapted from flask_minify