{% extends ‘index‘ %}
{% block title %}
个人中心
{% endblock %}
{% block main %}
<link href="" rel="stylesheet">
<ul class="nav nav-pills" style="margin-left: 30%">
<li><a href="{{ url_for(‘userr‘,user_id=user.id,tag = 1) }}">全部问答</a></li>
<li><a href="{{ url_for(‘userr‘,user_id=user.id,tag = 2) }}">全部评论</a></li>
<li><a href="{{ url_for(‘userr‘,user_id=user.id,tag = 3) }}">个人资料</a></li>
</ul>
{% block ab %}{% endblock %}
{% endblock %}
@app.route(‘/usercenter/<user_id>/<tag>‘)
@loginFirst
def usercenter(user_id,tag):
user=User.query.filter(User.id==user_id).first()
context={
‘user‘:user,
‘question‘: user.question,
‘comments‘: user.comments
}
if tag==‘1‘:
return render_template(‘usercenter1.html‘, **context)
elif tag==‘2‘:
return render_template(‘usercenter2.html‘, **context)
else:
return render_template(‘usercenter3.html‘, **context)