一、模板渲染
1、网页模板可以实现应用程序与网页布局的逻辑分开, 让你专注于pyhon代码的开发
2、网页模板已经有了, 那如何渲染它呢? 引入render_template包即可。
3、看一下渲染是否成功
二、控制语句
{% if %} {% endif %} : 条件
{% for %} {% endfor %}: 循环
循环用户及文章
三、模板继承
把所有模板公共的部分移出页面布局放入一个基础模板中, 所有使用它的模板可以导入该基础模板, 来实现模板的继承。
在我们的 microblog 应用程序中,在页面的顶部做一个导航栏, 所有页面都继承这个导航栏。
在index.html中继承base.html的格式
效果图