def index(): username = request.get_cookie('U', secret=secret()) password = request.get_cookie('P', secret=secret()) if check_user(username, password): return template('todo') else: return template('login', error=None)
def postlogin(): username = request.forms.get('username') password = request.forms.get('password') if check_user(username, password): response.set_cookie('U', username, secret=secret()) response.set_cookie('P', password, secret=secret()) redirect('/') else: return template('login', error='Wrong username or password. Please try again.')