if request.method == "GET":
return render_template("login.html")
elif request.method=="POST":
params = request.form
user_name = params.get("uname")
# 设置cookie
response = redirect(url_for('user.user_index'))
response.set_cookie("uname",user_name)
return response
else:
abort(405)
#退出
@user.route("/logout/")
def logout_api():
# response = make_response()
# #删除cookie
response = redirect(url_for('user.user_index'))
response.delete_cookie("uname")
return response
#index页面api
@user.route("/index/")
def user_index():
user_name = request.cookies.get("uname","游客")#读cookie
return render_template("index.html",uname=user_name)
联系客服