def post(): body = get_user_info() if UserModel.query.filter_by(username=body.username).first(): return response(status_code=status.HTTP_409_CONFLICT, message='User with this name already exists') user = UserModel(name=body.username, password=body.password) db.session.add(user) db.session.commit() data = user.as_dict() data[TOKEN] = encode_token(user.as_dict()) return response(status_code=status.HTTP_200_OK, data=data, message='Successfully registered')