I am using Python 3.5 to develop a web app with Flask. Having the following code:
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def main():
return render_template('main.html', show_hidden=False)
app.run()
and the template main.html:
<html>
<body>
<h1>Hey!</h1>
{% if show_hidden == True %}
<p>Hidden text</p>
{% endif %}
</body>
</html>
Right now this seems an unuseful feature, but I'll find a way to determine whether the hidden text should be displayed.
When the above code runs, the hidden text is shown although show_hidden is set to False. Furthermore, when it is turned to True the hidden text is displayed twice. As I have followed the docs this code is supposed to be working. Could someone please point me out what am I missing?
The == True is redundant, you can just check whether {% if show_hidden %}
Change :
{% if show_hidden == True %}
To :
{% if show_hidden %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With