from flask import Flask,render_template
app=Flask(__name__)
@app.route('/<is_login>/')
def index(is_login):
if is_login=='1':
user={'username':'张三',
'age':18}
return render_template('index.html',user=user)
else:
return render_template('index.html')
if __name__=='__main__':
app.run(debug=True)
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
{% if user %}
<a href="#">{{user.username}}</a>
<a href="#">注销</a>
{% else %}
<a href="#">登录</a>
<a href="#">注销</a>
{% endif %}
</body>
</html>
</body>