userbase.htmlcss
<!DOCTYPE html> <html lang="en"> <head> {% extends "text.html" %} <meta charset="UTF-8"> <link href="https://cdn.bootcss.com/bootstrap/4.0.0-beta/css/bootstrap.css" rel="stylesheet"> <link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"> <title>首页</title> </head> <body background="../static/img/WeChat%20Image_20171027161942.png" style="background-attachment: fixed;background-size: 100% 100%" > {% block personal_message %} <ul class="nav"> <li role="presentation"><a href="{{ url_for('pre',user_id=user.id,tag='1') }}"> 所有问答</a></li> <li role="presentation"><a href="{{ url_for('pre',user_id=user.id,tag='2') }}">所有评论</a></li> <li role="presentation"><a href="{{ url_for('pre',user_id=user.id,tag='3') }}">我的资料</a></li> </ul> {% block a %}{% endblock %} {% endblock %} </body> </html>
usercenter1.htmlhtml
{% extends "userbase.html" %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link href="https://cdn.bootcss.com/bootstrap/4.0.0-beta/css/bootstrap.css" rel="stylesheet"> <link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"> <title>首页</title> </head> <body> {% block a %} <div style="margin-left: 28%;margin-top: 1.5%"> <div class="card" style="width: 60rem;height:auto"> <div class="card-header"> <h2><a href="{{ url_for('pre',user_id=user.id,tag='1') }}"> {{ user.username }}</a></h2> </div> <div class="card-body"> <ul style="font-size: large;list-style-type: none;"> <p class="text-info"style="font-size: 30px">全部问答</p> {% for foo in user.question %} <div> <li> <a href="#">{{ foo.author.username }}</a> <span class="">{{ foo.creat_time }}</span><br> <a href="{{ url_for("pinglun",question_id=foo.id) }}">{{ foo.title }}</a> <p>{{ foo.detail }}</p> </li></div> {% endfor %} </ul> </div> </div> </div> {% endblock %} </body> </html>
usercenter2.hemlbootstrap
{% extends "userbase.html" %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link href="https://cdn.bootcss.com/bootstrap/4.0.0-beta/css/bootstrap.css" rel="stylesheet"> <link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"> <title>首页</title> </head> <body> {% block a %} <div style="margin-left: 28%;margin-top: 1.5%"> <div class="card" style="width: 60rem;height:auto"> <div class="card-header"> <h2><a href="{{ url_for('pre',user_id=user.id,tag='1') }}"> {{ user.username }}</a></h2> </div> <div class="card text-left" style="width: 60rem;height: auto"> <div class="card-body"> <ul style="font-size: large;list-style-type: none"> <p class="text-info"style="font-size: 30px">全部评论</p> {% for foo in user.comment %} <li> <a href="#">{{ foo.author.username }}</a> <span>{{ foo.creat_time }}</span><br> <p>{{ foo.detail }}</p> </li> {% endfor %} </ul></div> </div> </div> {% endblock %} </body> </html>
usercenter3.htmlapp
{% extends "userbase.html" %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link href="https://cdn.bootcss.com/bootstrap/4.0.0-beta/css/bootstrap.css" rel="stylesheet"> <link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"> <title>首页</title> </head> <body> {% block a %} <div style="margin-left: 28%;margin-top: 1.5%"> <div class="card" style="width: 60rem;height:auto"> <div class="card-header"> <h2><a href="{{ url_for('pre',user_id=user.id,tag='1') }}"> {{ user.username }}</a></h2> </div> <div class="card text-left" style="width: 60rem;height: auto"> <div class="card-body"> <ul style="font-size: large;list-style-type: none"> <p class="text-info"style="font-size: 30px">我的信息</p> <li><p>用户名:{{ user.username }}</p></li> <li><p>Id:{{ user.id }}</p></li> <li><p>内容篇幅:{{ user.question|length }}</p></li> </ul> </div> </div> </div> {% endblock %} </body> </html>
defurl
@app.route('/presonal_message/<user_id>/<tag>') @log def pre(user_id,tag): user=User.query.filter(User.id==user_id).first() context={ 'user':user } 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)