Giter Site home page Giter Site logo

flask-htmlmin's Introduction

flask-htmlmin's People

Contributors

bfontaine avatar dependabot[bot] avatar hamidfzm avatar jamilatta avatar matt-wisdom avatar mrf345 avatar runar-rkmedia avatar s-t-e-v-e-n-k avatar timesqueezer avatar timgates42 avatar yecril71pl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

flask-htmlmin's Issues

unexpected call to parse_endtag

Hi. Getting a sporadic error 'unexpected call to parse_endtag". I haven't been able to replicate the issue reliably.

Occurs here in parse.py file in htmlmin.
assert rawdata[i:i+2] == "</", "unexpected call to parse_endtag"

However as a suggestion, perhaps a try except AssertionError should be added to the reponse_minify method. This way even if the error does occur, the final webpage is still rendered as the original unminified response is returned.

Error try to use HTMLmin with send_from_directory

The response when turn on HTMLMIN on my App.

This is my view;

@main.route("/media/<path:filename>", methods=['GET'])
def download_file_by_filename(filename):
    media_root = current_app.config['MEDIA_ROOT']
    return send_from_directory(media_root, filename)

The response is:

screen shot 2016-06-23 at 12 10 56

Example not working

I'm testing the example provided in README:

from flask import Flask, render_template
from flask_htmlmin import HTMLMIN
    
app = Flask(__name__)
app.config['MINIFY_PAGE'] = True

htmlmin = HTMLMIN(app)
# or you can use HTMLMIN.init_app(app)
# pass additional parameters to htmlmin
# HTMLMIN(app, **kwargs)

@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()

And this is my templates/index.html

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>

  <body>
    <div>
      Hello
    </div>
    <div>
      World
    </div>
  </body>
</html>

I'm using python 3.7.2 and there is no minified output.

OpenTagNotFoundError() redirect code 302

if response.content_type == u'text/html; charset=utf-8':

if you use flask.redirect, this redirection with code 302 and the response: https://github.com/pallets/werkzeug/blob/4397e61daf66ad43bd5668741c5d876de116a71f/werkzeug/utils.py#L373

'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n'
'<title>Redirecting...</title>\n'
'<h1>Redirecting...</h1>\n'
'<p>You should be redirected automatically to target URL: '
'<a href="%s">%s</a>. If not click the link.'

for htmlmin.parser is not valid:
https://github.com/mankyd/htmlmin/blob/dff1163a1ec25fe94aeaeefe702377b5a9e912b3/htmlmin/parser.py#L261

that gives an error OpenTagNotFoundError()

Can we read htmlmin options from the flask config file?

Hi, thanks for the tool!

What do you think about allowing these settings to be set in the app.config?

default_options = {
            'remove_comments': True,
            'reduce_empty_attributes': True,
            'remove_optional_attribute_quotes': False
        }
default_options.update(kwargs)

As well as the other options for htmlmin from https://htmlmin.readthedocs.io/en/latest/reference.html?

Personally, I'd really like to add the "remove_empty_space". Somehow my output has whitespace between all tags, for example the closing tags on my homepage look like this -

</div> </div> </div> </body> </html>

utf8 crash

Hello

Tried out the module .. ran into an error.
[2018-08-01 11:14:04 +0000] [2320] [INFO] Starting gunicorn 19.9.0
[2018-08-01 11:14:04 +0000] [2320] [INFO] Listening at: http://0.0.0.0:5000 (2320)
[2018-08-01 11:14:04 +0000] [2320] [INFO] Using worker: gevent
[2018-08-01 11:14:04 +0000] [2324] [INFO] Booting worker with pid: 2324
[2018-08-01 11:14:04 +0000] [2325] [INFO] Booting worker with pid: 2325
[2018-08-01 11:14:09 +0000] [2325] [ERROR] Error handling request /
Traceback (most recent call last):
File "/home/anon/miniconda2/lib/python2.7/site-packages/gunicorn/workers/base_async.py", line 56, in handle
self.handle_request(listener_name, req, client, addr)
File "/home/anon/miniconda2/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 160, in handle_request
addr)
File "/home/anon/miniconda2/lib/python2.7/site-packages/gunicorn/workers/base_async.py", line 107, in handle_request
respiter = self.wsgi(environ, resp.start_response)
File "/home/anon/miniconda2/lib/python2.7/site-packages/flask/app.py", line 2309, in call
return self.wsgi_app(environ, start_response)
File "/home/anon/miniconda2/lib/python2.7/site-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/home/anon/miniconda2/lib/python2.7/site-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/anon/miniconda2/lib/python2.7/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/home/anon/miniconda2/lib/python2.7/site-packages/flask/app.py", line 1816, in full_dispatch_request
return self.finalize_request(rv)
File "/home/anon/miniconda2/lib/python2.7/site-packages/flask/app.py", line 1833, in finalize_request
response = self.process_response(response)
File "/home/anon/miniconda2/lib/python2.7/site-packages/flask/app.py", line 2112, in process_response
response = handler(response)
File "/home/anon/miniconda2/lib/python2.7/site-packages/flask_htmlmin/init.py", line 35, in response_minify
self.html_minify.minify(response.get_data(as_text=True))
File "/home/anon/miniconda2/lib/python2.7/site-packages/werkzeug/wrappers.py", line 989, in get_data
rv = rv.decode(self.charset)
File "/home/anon/miniconda2/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x8b in position 1: invalid start byte

disable_css_min argument leads to error in initialization

Using the example I get this:

htmlmin = HTMLMIN(app, remove_comments=False, remove_empty_space=True, disable_css_min=True)

TypeError: unexpected keyword argument 'disable_css_min'

Also, when I install via pip, I get this: Using legacy setup.py install for Flask-HTMLmin, since package 'wheel' is not installed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.