首页列表显示全部问答,完成问答详情页布局。
- 首页列表显示全部问答:
- 将数据库查询结果传递到前端页面 Question.query.all()
- 前端页面循环显示整个列表。
- 问答排序
- 完成问答详情页布局:
- 包含问答的全部信息
- 评论区
- 以往评论列表显示区。
- 在首页点击问答标题,链接到相应详情页。
html:
{% extends'base.html' %} {% block title %} 首页 {% endblock %} {% block head %} <link rel="stylesheet" href="{{ url_for('static',filename='css/index.css') }}" type="text/css"> {% endblock %} {% block main %} <body id="myBody"> <div class="indexone"> <ul class="list-group"> {% for foo in questions %} <li class="list-group-item"> <span class="glyphicon glyphicon-leaf" aria-hidden="true"></span> <a href="#" style="font-family: 幼圆">{{ foo.author.username }}</a> <br> <a href="{{ url_for('context') }}" style="font-family: 幼圆">{{ foo.title }}</a><br> <span class="badge" style="font-family: 幼圆">{{ foo.creat_time }}</span> <p style="font-family: 幼圆;color: #002D54;">{{ foo.detail }}</p> <div class="meta"> <a class="collection-tag"> <span style="font-family: 幼圆">社会热点</span> </a> <a class="collection-tag"> <span style="font-family: 幼圆"> 浏览: </span><span style="font-family: 幼圆;color: red"> 555 </span> </a> <a class="collection-tag"> <span style="font-family: 幼圆"> 评论: </span><span style="font-family: 幼圆;color: red"> 890 </span> </a> <span style="font-family: 幼圆"> 点赞: </span><span style="font-family: 幼圆;color: red"> 1234 </span> </div> </li> {# <li>#} {# <div class="author">#} {# <a class="nickname" href="http://www.mafengwo.cn/u/80594779.html" style="font-family: 幼圆">启蒙高小五</a>#} {# </div>#} {# <div class="title">#} {# <p class="wenzi">#} {# 完全是误打误撞去的。也算是当地特色。不过奇怪的是,大家全都热衷买外卖,并没有多少进店吃的。蟹黄小笼包貌似特别有名,不过对于海鲜没兴趣的我,并没有吃。点了素烧卖、大馒头、臭豆腐,每菜都有自己的味道,挺不错的。#} {# </p>#} {# <div class="meta">#} {# <a class="collection-tag">#} {# <span style="font-family: 幼圆">社会热点</span>#} {# </a>#} {# <a class="collection-tag">#} {# <span style="font-family: 幼圆"> 浏览: </span><span#} {# style="font-family: 幼圆;color: red"> 888 </span>#} {# </a>#} {# <a class="collection-tag">#} {# <span style="font-family: 幼圆"> 评论: </span><span#} {# style="font-family: 幼圆;color: red"> 1000 </span>#} {# </a>#} {# <span style="font-family: 幼圆"> 点赞: </span><span#} {# style="font-family: 幼圆;color: red"> 1000 </span>#} {# </div>#} {##} {# </div>#} {# </li>#} {% endfor %} </ul> </div> </body> </html> {% endblock %}

详情页:
{% extends'base.html' %} {% block title %} 问答详情 {% endblock %} {% block head %} <link rel="stylesheet" href="{{ url_for('static',filename='css/context.css') }}" type="text/css"> {% endblock %} {% block main %} <div class="container"> <div class="chbox"> <h3 style="font-family: 楷体;text-align: center;font-size: 40px">详情页</h3> <ul> <li class="list-group-item"> <span class="glyphicon glyphicon-leaf" aria-hidden="true"></span> <a href="#" style="font-family: 幼圆">username</a> <br> <a href="{{ url_for('context') }}" style="font-family: 幼圆">title</a><br> <span class="badge" style="font-family: 幼圆">creat_time</span> <p style="font-family: 幼圆;color: #002D54;">detail</p> </li> </ul> <form method="post" action="{{ url_for('context') }}"> <div class="title" style="text-align: left"> <label for="biaoti" style="font-size: 20px">Write down your answer</label><br> <textarea class="form-control" rows="10" placeholder="请输入要发布的内容" name="detail"></textarea> </div> <div style="text-align: center"> <button type="submit" id="fabu">发送</button> </div> </form> </div> </div> {% endblock %}

浙公网安备 33010602011771号