标签:icon run end static jquer author temp 文件 数据库查询
py文件
@app.route(‘/‘) def moban(): context = { ‘wenda‘: Wenda.query.order_by(‘creat_time‘).all() } return render_template(‘moban.html‘,**context)
html
<ul class="news-list"> {% for foo in wenda %} <li class="list-group-item"> <span class="glyphicon glyphicon-leaf" aria-hidden="true"></span> <a href="#">{{ foo.author.username}}</a> <br> <a href="{{ url_for(‘detail‘,wenda_id= foo.id) }}">{{ foo.title }}</a> <br> <span class="badge" >{{ foo.creat_time }}</span> <p style="background-color: aqua">{{ foo.detail }}</p> </li> {% endfor %}
2.
{% extends ‘moban.html‘ %} {% block title %}详情界面{% endblock %} {% block head %} <link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script> <script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script> {% endblock %} {% block body %} <div class="col-md-2 column "></div> <div class="col-md-8 column "> <ul class="list-unstyled"> <li> <h2 href="#" class="text-center">{{ wend.title }}</h2> <br> <p class="text-center"> <a href="#"> <small>{{ wend.author.username }}</small> </a>    <span class="pull-center"><small>{{ wend.creat_time }}</small></span> </p> <p>{{ wend.detail }}</p> <form> <div class="form-group"> <textarea name="comment" class="form-control" rows="6" id="comment" placeholder="请输入评论"></textarea> </div> <button type="submit" class="btn btn-default">发送</button> </form> </li> </ul> </div> <div class="col-md-2 column "></div> {% endblock %}
3.
@app.route(‘/detail?<wenda_id>‘) def detail(wenda_id): wen = Wenda.query.filter(Wenda.id == wenda_id).first() return render_template(‘detail.html‘,wend=wen)
标签:icon run end static jquer author temp 文件 数据库查询
原文地址:http://www.cnblogs.com/qq724852210/p/7995018.html