flask render_template giving error for commented html code

301 views Asked by At

It's weird that flask's render_template was throwing an exception which was generated because of my commented code in html. below is the html comment I made

<!-- <!DOCTYPE html>
<html>
    <head>
        <title>Welcome to XYZ</title>
    </head>
    <body>
            <p>{{ result }}</p>
            <p> {{ direct_url_for_login }}</p>
            <p> {{ _company }}</p>

            {% for key, value in result.items() %}
            <p>{{ key }}</p>
            <p>{{ value }}</p>
            {% endfor %}
    </body>
</html> -->

I am just curious If there is something I am doing wrong , or it's an expected behaviour. because I was getting result is undefined exception thrown, where i kept the render_template part. Thanks in Advance.

try:
    ...
    ...
    return render_template('foo.html',**locals()), 200
except Exception as e:
    return jsonify({'message':str(e)}), 500
1

There are 1 answers

2
BadRequest On BEST ANSWER

Sure it's normal ... you are trying to render an empty page.

Why do you put in comment all your page ?

Maybe you could have your answer there : Comments not working in jinja2

or there : http://jinja.pocoo.org/docs/2.10/templates/#comments