标签:信息 title containe efault 首页 传递 render css pcdn
python文件 @app.route(‘/‘) def lx(): context = { ‘questions‘: Ques.query.all() } return render_template(‘linf.html‘, **context)
<ul class="news-list"> {% for foo in question %} <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‘,question_id= foo.id) }}">{{ foo.title }}</a> <br> <span class="badge" >{{ foo.creat_time }}</span> <p style="background-color: aqua">{{ foo.detail }}</p> </li> {% endfor %} </ul>
@app.route(‘/detail/<question_id>‘) def detail(question_id): quest = Ques.query.filter(Ques.id==question_id).first() return render_template(‘detail.html‘,quest=quest)
{% extends ‘base.html‘ %} } {% block title %}详情页{% endblock %} {% block head %} <!-- 引入 Bootstrap --> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> {% endblock %} {% block main %} <h1>问题详情</h1> <div class="container"> <div class="row clearfix"> <div class="col-md-12 column"> <h3 class="text-center"> title </h3> <p class="text-center"> detail </p> <form role="form"> <div class="form-group"> <label for="exampleInputEmail1">Write down your answer~~</label><input type="email" class="form-control" id="exampleInputEmail1" /> </div> <button type="submit" class="btn btn-default">Submit</button> </form> </div> </div> </div> {% endblock %}
@app.route(‘/detail?<question_id>‘) def detail(question_id): quest = Question.query.filter(Question.id == Question_id).first() return render_template(‘detail.html‘,quest=quest)
标签:信息 title containe efault 首页 传递 render css pcdn
原文地址:http://www.cnblogs.com/linf/p/7986018.html