制作首页的显示列表。

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

无序列表

<ul >

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ul>

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

{% extends'base.html' %}
{% block title %}
    Home
{% endblock %}
{% block head %}
    <link rel="stylesheet" href="{{ url_for('static',filename='css/shouye.css')}}" type="text/css">
{% endblock %}
{% block main %}
<body>

<br>
{#<img id="pig" src="../static/images/pig.jpg">#}
<ul class="comment">
    <img class="comment_pic"  src="../static/images/comment.png">
    <p class="wenzi">Question</p>
    <li class="detail">
        <span class="icon" aria-hidden="true"></span>
        <a href="#">username</a>
        <br>
        <a href="#">title</a>
        <span class="badge">creat_time</span>
        <p >detail{{ question }}</p>
    </li></ul>

</body>
{% endblock %}
</html>
@app.route('/')
def home():
    context={
        'question':'123456'
    }
    return render_template('shouye.html',**context)

 

posted @ 2017-12-01 11:51  078刘凯敏  阅读(127)  评论(0编辑  收藏  举报