1. 在首页添加显示问答的列表,并定义好相应的样式。
无序列表
<ul >
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
<div class="list-container"> <ul class="note-list"> <li class="list-container-item"> <span class="glyphicon glyphicon-leaf" aria-hidden="true"></span> <a href="#">{{ user }}</a> <br> <a href="#">{{ title }}</a> <span style="margin-left: 450px;background-color: #cccccc;border-radius: 25px;font-size: 14px"id="badge" >发布时间</span> <p>{{ detail }}</p> </li> </ul> </div>
2. 用字典向index.html传递参数。
@app.route('/') def index(): context ={ 'user':'usename', 'title':'this is title', 'detail':'this is detail' } return render_template('index.html',**context)