制作首页的显示列表。

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

无序列表

<ul >

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ul>

<ul class="list-group">

    <li class="list-group-item" style=" 800px">
      <span class="glyphicon glyphicon-left" aria-hidden="true"></span>
        <a  href="#" target="_blank">{{ user }}</a>
        <br>
         <a  href="#">{{ title }}</a>
     <span class="badge">发布时间:{{ time }}</span>
              <p style="">{{ detail }}
    </p>

    </li>


</ul>

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

@app.route('/')
def index():
    context={
        'user':'hll',
        'title':'发布”',
        'time':'2017-11-30',
        'detail':'发布内容', 
    } 
    return render_template('basic.html',**context)
原文地址:https://www.cnblogs.com/GAODASHANG/p/7929486.html