制作首页的显示列表。
1. 在首页添加显示问答的列表,并定义好相应的样式。
无序列表
<ul >
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
2. 用字典向index.html传递参数。
{% extends 'base.html' %} {% block title %}首页{% endblock %} {% block head %} <link href="{{ url_for('static',filename='css/index.css') }}" rel="stylesheet" type="text/css"> <script src="{{ url_for('static',filename='js/index.js') }}"></script> {% endblock %} {% block main %} <p>{{ username }}contextx</p> <ul class="list-group"style=""> <li class="list-group-item"> <span class="glyphicon glyphicon-leaf"aria-hidden="true"></span> <a href="#">username</a> <br> <a href="*">title</a> <span class="badge">creat_time</span> <p style="">detail{{ question }}</p> </li> </ul> <body background="http://img5.imgtn.bdimg.com/it/u=1444609104,245569973&fm=27&gp=0.jpg"></body> {% endblock %}
@app.route('/') def index(): context = { 'question':'python20171201' } return render_template('index.html',**context)