首页列表显示全部问答,完成问答详情页布局
- 首页列表显示全部问答:
- 将数据库查询结果传递到前端页面 Question.query.all()
- 前端页面循环显示整个列表。
- 问答排序
- 完成问答详情页布局:
- 包含问答的全部信息
- 评论区
- 以往评论列表显示区。
- 在首页点击问答标题,链接到相应详情页。
@app.route('/') def home(): context={ 'questions': Question.query.all() } return render_template('home.html',**context)
@app.route('/detail/') def detail(): return render_template('detail.html')
index
{% extends 'base.html' %}
{% block title %}index{% endblock %}
{% block head %}
<link href="{{ url_for('static',filename='CSS/index.css') }}" rel="stylesheet" type="text/css">
{% endblock %}
{% block main %}
<div class="img">
<ul>
<li>
<div class="content">
<div class="author">
<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 %}
detail
{% extends 'base.html' %}
{% block title %}
问答详情页
{% endblock %}
{% block head %}
<link type="text/css" rel="stylesheet" href="../static/css/detail.css">
{% endblock %}
<div class="detail">
<h2>title</h2>
<a href="#">username</a>
<span>creat_time</span>
<div class="p">
<p>detail</p>
</div>
<textarea rows="5"></textarea><br>
<button >发送</button>
<br>
{% endblock %}
浙公网安备 33010602011771号