制作首页的显示列表。

1. 在首页添加显示问答的列表,并定义好相应的样式。

无序列表

<ul >

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ul>

2. 用字典向index.html传递参数。

{% extends 'shouye.html' %}
{% block title %}首页{% endblock %}
{% block head %}
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="../static/css/sywenda.css">
{% endblock %}
{% block main %}
   <div class="label">
    <ul class="list-group">
            <li class="list-group-item">
                <a href="#">{{ username }}</a><br>
                <a href="#">电影:{{ title }}</a><br>
                <a href="#">反馈:{{ detail }}</a><br>
                <span class="badge" style="margin-left: 60%">{{ creat_time }}发布时间</span>
                <p style="margin-left: 25%"></p>
            </li>
            <br>
            <li class="list-group-item">
                <a href="#">{{ username }}</a><br>
                <p></p><br>
                <p></p><br>
                <span class="badge" style="margin-left: 60%">{{ creat_time }}发布时间</span>
                <p style="align-content: center"></p>
            </li>
        </ul>

   </div>
{% endblock %}
@app.route('/')
def shouye():
    context={
        'questions':Question.query.order_by('-creat_time').all()
    }
    return render_template('sywenda.html',**context)

 

posted on 2017-12-01 15:10  104鲍珊珊  阅读(115)  评论(0编辑  收藏  举报

导航