note.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:sanic-auth 作者: pyx 项目源码 文件源码
def login(request):
    message = ''
    if request.method == 'POST':
        username = request.form.get('username')
        password = request.form.get('password')
        # for demonstration purpose only, you should use more robust method
        if username == 'demo' and password == '1234':
            # use User proxy in sanic_auth, this should be some ORM model
            # object in production, the default implementation of
            # auth.login_user expects User.id and User.name available
            user = User(id=1, name=username)
            auth.login_user(request, user)
            return response.redirect('/')
        message = 'invalid username or password'
    return response.html(LOGIN_FORM.format(message))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号