制作首页的显示列表。
2017-12-01 14:29 095罗其婷 阅读(144) 评论(0) 收藏 举报1. 在首页添加显示问答的列表,并定义好相应的样式。
无序列表
<ul >
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
2. 用字典向index.html传递参数。
{% extends 'base.html' %} {% block title %}首页{% endblock %} {% block main %} <div class="box"> <ul class="list-group"> <li class="list-group-item"> <a href="#">{{ username }}</a><br> <a href="#">问题:{{ title }}</a><br> <a href="#">详情:{{ detail }}</a> <span class="badge" style="margin-left: 60%">{{ create_time }}发布时间</span> <p style="margin-left: 25%"></p> </li> <br> <li class="list-group-item"> <a href="#">{{ username }}</a><br> <a href="#">青春的意义</a><br> <a href="#">最美好的</a><br> <span class="badge" style="margin-left: 60%">{{ create_time }}发布时间</span> <p style="align-content: center"></p> </li> </ul> </div> {% endblock %}
@app.route('/index/')
def index():
context = {
'title': '努力的意义是什么?',
'detail': '为了看到更大的社会,为了有自己选择人生的机会,为了不向讨厌的人低头。为了有喜欢的人出现的时候不用卑微的低着头,而是充满自信的说:“你很好,但我也不差”',
}
return render_template('index.html',**context)
浙公网安备 33010602011771号