- 变量代码快{ {}}
- 控制代码块{%%}
示例模板
<!-- app/templates/index.html-->
<html>
<head>
<title>{
{title}} - microblog</title>
</head>
<body>
<h1>Hello, {
{user.nickname}}!</h1>
{
{user['nickname']}}<br>
{
{my_list.2}}<br>
</body>
</html>
- 动态内容在 { { … }} 中。
更改视图文件使用模板
# app/views.py
from flask import render_template # 调用这个可以返回模板
from app import app
@app.route('/')
@app.route('/index')
def index():
user = {
'nickname': 'Miguel' } # fake user
my_list =