kratos2333
2/11/2019 - 9:52 AM

TemplateControlFollow

from flask import Flask, render_template
app = Flask(__name__)


@app.route('/')
def index():
    mylist = [1,2,3,4,5]
    puppy = ['peggy','qiuqiu','lulu']
    return render_template('templateControlFlow.html',mylist=mylist, puppy = puppy)

if __name__ == '__main__':
    app.run(debug=True)
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Basic</title>
</head>
<body>
<ul>
    {% for element in mylist %}
        <li>{{ element }}</li>
    {% endfor %}
</ul>
{% if 'peggy' in puppy %}
    <p>Found you peggy</p>
{% else %}
    <p>Peggy is not here</p>
{% endif %}
</body>
</html>
1
2
3
4
5
Found you peggy