Giter VIP home page Giter VIP logo

Comments (4)

mgood avatar mgood commented on July 20, 2024

Yeah, I've just merged #20 to add a warning when the </body> tag isn't present. I've left the check for </body> in so far to make sure the toolbar is only inserted into complete HTML pages. I've been thinking how to remove that requirement, but it could screw up a few situations.

Some apps may accidentally serve non-HTML pages with "Content-Type: text/html". I'm less concerned about this since it's an application bug that can be solved by fixing the content-type, but still might catch some users by surprise.

However, it's more of an issue for apps rendering HTML snippets for inclusion into a full page. For example, using JS to request and inject rendered HTML widgets. Checking "is_xhr" should avoid this for JavaScript XHR requests, though situations where apps send partial-HTML responses that would be screwed up by inserting the toolbar.

So, I'm trying to think about ways to conveniently allow apps to distinguish when it's ok to insert the toolbar if necessary.

from flask-debugtoolbar.

mgood avatar mgood commented on July 20, 2024

Maybe just checking if the document starts with <!doctype html> is sufficient to determine that it's ok to insert the toolbar at the end, if HTML fragments generally don't include a doctype declaration.

from flask-debugtoolbar.

mgood avatar mgood commented on July 20, 2024

Yeah, it didn't seem like it was common to include the <!doctype html> declaration in HTML fragment responses, so looking for that also appears that it will be a reasonable sign that it's ok to include the toolbar. So, if the document is missing a </body> but starts with <!doctype html> (case insensitive) it will append the toolbar.

from flask-debugtoolbar.

agumonkey avatar agumonkey commented on July 20, 2024

Suggesting to include this as a note in the http://flask-debugtoolbar.readthedocs.org/en/latest/ documentation. While testing html-less Flask (rare case I know) I was confused about why no toolbar was showing and spend 10 minutes rereading everything. Thanks for github issues I would never have guessed.

from flask-debugtoolbar.

Related Issues (20)

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.