@app.route('/')
def index():
contex={
'questions':Question.query.order_by('-creat_time').all()
}
return render_template('index.html',**contex)
{% extends 'daohang.html' %}
{% block title %}首页{% endblock %}
{% block main %}
<p>{{ user }}contex</p>
<div class="box">
<ul class="list-group" style=" padding-left: 0; padding-right: 10px; box-shadow: rgba(0, 0, 0, 0.498039) 0 0 0 0;">
{% for foo in questions %}
<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>
<span class="badge">{{ foo.creat_time }}</span>
<p>{{ foo.detail }}</p>
</li>
{% endfor %}
</ul>
</div>
{% extends 'daohang.html' %}
{% block title %}问答详情{% endblock %}
{% block main %}
<div class="page-header">
<h3>Title{{ ques }}<br>
<small>author {{ ques.author_id }}{{ ques.creat_time }}</small>
</h3>
</div>
<p class="lead">detail{{ ques.detail }}</p>
<hr>
<form action="{{ url_for('question') }}" method="post">
<div class="form-group">
<textarea name="new_comment" class="form-control" rows="3" id="new_comment" placeholder="write your comment"></textarea>
</div>
<button type="submit" class="btn btn-default">发送</button>
</form>
<ul class="list-group" style="margin: 10px"></ul>
{% endblock %}