11.29

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

无序列表

<ul >

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ul>

{%  block main %}
    <img src="{{ url_for('static',filename='images/qalogo.png') }}"alt="qa">
    <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="#">{{ user }}</a>
            <br>
            <a href="#">标题</a>
            <span class="badge">发布时间</span>
            <a style="">内容</a>
        </li>

    </ul>
{% endblock %}

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

@app.route('/')
def shouye():
    context={
        'user':'mis3'
    }
    return render_template('shouye.html',**context)
原文地址:https://www.cnblogs.com/chenyanxi123/p/7920953.html