auth.py 文件源码

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

项目:FlaskService 作者: b96705008 项目源码 文件源码
def configure_auth(app, config):
    auth = HTTPBasicAuth()

    @auth.get_password
    def get_password(username):
        # fetch pwd from db
        if username == 'root':
            return '1234'
        return None

    @auth.error_handler
    def unauthorized():
        return make_response(jsonify({'error': 'Unauthorized access'}), 401)

    return auth
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号