У меня есть следующий тест сниппет:Как выйти из бутылки Python?
def check(username, password):
if username == "b" and password == "password":
return True
return False
@route('/logout')
@route('/logout', method="POST")
def logout():
# template with a logout button
# this does redirect successfully, but this shouldn't happen
redirect('/after-login')
@route('/after-login')
@auth_basic(check)
def after_login():
return "hello"
@route('/login')
@route('/login', method="POST")
def login():
return template("views/login/login_page")
username = post_get('username')
password = post_get('password')
Я пытаюсь выйти из системы, но я не смог найти какие-либо ресурсы о том, как это сделать. В принципе, я попробовал dir (response) и dir (request) и не нашел никаких функций, которые, как представляется, отключили сеанс (в основном, попытку сброса файлов cookie), если я не закрою браузер.
Кстати, вы можете свернуть ваши вызовы '@ route' в один. '@route ('/ login', method = ['GET', 'POST'])' –