1. 在首頁添加顯示問答的列表,並定義好相應的樣式。css
無序列表html
<ul >app
<li>Coffee</li>url
<li>Tea</li>spa
<li>Milk</li>code
</ul>htm
{% 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傳遞參數。blog
@app.route('/')
def zhuye():
context={
'user':'wudaiqi:',
'title': 'wahahaha',
'time': 'today',
'detail':'burberry*kriswu'}
return render_template('zhuye.html',**context)