制作首页的显示列表

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

无序列表

<ul >

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ul>

{% extends 'base.html' %}

{% block title %}Home{% endblock %}

{% block head %}
    <link href="{{ url_for('static',filename='css/zhuye.css') }}" rel="stylesheet" type="text/css">
    <p>{{ user }} context</p>
{% endblock %}

{% block main %}
<div class="img">
        <ul>
            <li>
                <div class="content">
                    <div class="author">
{#                        <img src="{{ url_for('static',filename='image/') }}">#}
                        <a href="#">username</a>
                        <span>creat_time</span>
                    </div>
                    <br>
                    <a class="title" href="#">title</a><br>
                    <p>detail</p>
                </div>
            </li>
        </ul>


</div>
{% endblock %}

 

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

@app.route('/')
def zhuye():
     context={
        'user':'wudaiqi:',
        'title': 'wahahaha',
        'time': 'today',
        'detail':'burberry*kriswu'}
     return render_template('zhuye.html',**context)

 

posted @ 2017-12-02 21:17  057吴代祺  阅读(87)  评论(0编辑  收藏  举报