main.py

@app.route('/')
def index():
    return render_template('index.html',mylist=[1,2,3,4]) #传递mylist参数
    
@app.template_filter('reverse')  # 添加模板过滤器
def reverse_filter(s):           # 倒序输出
    return s[::-1]

if __name__ == "__main__":
    app.run()
index.html

{% for x in mylist | reverse %}
<p>{{ x }}</p>
{% endfor %}