我在下面有一个代码,它设置 cookie,然后将此 cookie 添加到具有set_cookies
函数的响应中。但是,即使我返回响应,我也会收到以下错误:
ValueError: View function did not return a response
我的代码就是这样的:
def login():
if request.method == "POST":
timestamp = str(int(time.time()))
cookie = timestamp+'user'
cookie = base64.b64encode(cookie.encode('utf-8')).decode('utf-8')
resp = make_response()
resp = resp.set_cookie("LoginCookie",cookie)
return resp