Beispiel #1
0
 def post(self, username):
     data = User.parser.parse_args()
     user = UserModel.get_by_username(username)
     if user:
         return {'message': 'user exits'}
     user = UserModel(username=username, email=data.get('email'))
     user.set_password(data.get('password'))
     user.add()
     return user.as_dict(), 201
Beispiel #2
0
 def post(self, username):
     """ create a user"""
     data = User.parser.parse_args()
     user = UserModel.get_by_username(username)
     if user:
         return {'message': 'user already exist'}
     user = UserModel(username=username, email=data['email'])
     user.set_password(data['password'])
     user.add()
     return user.as_dict(), 201
Beispiel #3
0
 def post(self, username):
     ''' 创建用户 '''
     #print(request.get_json())
     data = User.parser.parse_args()  #3、引用检查
     user = UserModel.get_by_username(username)
     if user:
         return {'message': 'user already exist'}
     user = UserModel(username=username, email=data['email'])
     user.set_password(data['password'])
     user.add()  #引用add方法
     return user.as_dict(), 201  #, 201表示状态
 def post(self, username):
     """
     create a user
     :param username:
     :return:
     """
     data = User.parser.parse_args()
     user = UserModel.get_by_username(username)
     if user:
         return {'message': f"user {username} already exist."}
     user = UserModel(username=username, email=data.get('email'))
     user.set_password(data.get('password'))
     user.add()
     return user.as_dict(), 201