from flask import Flask, url_for
from flask import render_template
from jinja2 import Environment, FileSystemLoader
app = Flask(__name__)
persons = [
{"name": "Алексей", "old": 18, "weight": 78.5},
{"name": "Николай", "old": 28, "weight": 82.3},
{"name": "Иван", "old": 33, "weight": 94.0}
]
file_loader = FileSystemLoader('templates')
env = Environment(loader=file_loader)
tm = env.get_template('/index.html')
msg = tm.render(persons=persons)
print(msg)
@app.route("/")
def index():
print(url_for('index'))
return render_template('index.html', persons=persons)
if __name__=="__main__":
app.run(debug=True)
<!DOCTYPE html>
<html>
<head>
<link type="text/css" href="{{ url_for('static', filename='css/style.css')}}" rel="stylesheet" />
</head>
<body>
<div class=page>hello</div>
<ul>
{% for u in persons -%}
{{u.name,u.old}}
{% endfor -%}
</ul>
</body>
</html>