api.py 文件源码

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

项目:pets-api 作者: fromzeroedu 项目源码 文件源码
def post(self):
        if not "app_id" in request.json or not "app_secret" in request.json:
            error = {
                "code": "MISSING_APP_ID_OR_APP_SECRET"
            }
            return jsonify({'error': error}), 400
        existing_app = App.objects.filter(app_id=request.json.get('app_id')).first()
        if existing_app:
            error = {
                "code": "APP_ID_ALREADY_EXISTS"
            }
            return jsonify({'error': error}), 400
        else:
            # create the credentials
            salt = bcrypt.gensalt()
            hashed_password = bcrypt.hashpw(request.json.get('app_secret'), salt)
            app = App(
                app_id=request.json.get('app_id'),
                app_secret=hashed_password
            ).save()
            return jsonify({'result': 'ok'})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号