Change the value of a variable inside a loop

Try also dictionary-based approach. It seems to be less ugly. {% set vars = {‘foo’: False} %} {% for item in items %} {% if vars.update({‘foo’: True}) %} {% endif %} {% if vars.foo %} Ok(1)! {% endif %} {% endfor %} {% if vars.foo %} Ok(2)! {% endif %} This also renders: Ok(1)! Ok(2)!

Creating link to an url of Flask app in jinja2 template

I feel like you’re asking two questions here but I’ll take a shot… For the posting url you’d do this: <a href=”https://stackoverflow.com/questions/11124940/{{ url_for(“post_blueprint.get_post’, year=year, month=month, title=title)}}”> {{ title }} </a> To handle static files I’d highly suggest using an asset manager like Flask-Assets, but to do it with vanilla flask you do: {{ url_for(‘static’, filename=”[filenameofstaticfile]”) … Read more