Пример #1
0
    def post(self, *args, **kwargs):
        # receive
        account = str(self.get_json_argument("account"))
        password = str(self.get_json_argument("password"))
        gender = str(self.get_json_argument("gender"))
        birthday = str(self.get_json_argument("birthday"))
        height = str(self.get_json_argument("height"))
        weight = str(self.get_json_argument("weight"))

        uid = uuid.uuid5(uuid.NAMESPACE_DNS, account)
        uid = str(uid)
        user_id = ''.join(uid.split('-'))

        user = User.create_user(user_id, account, password, gender, birthday,
                                height, weight)

        if user == None:
            data = {
                'code': '400',
                'message': 'Account already exists',
            }
            self.write(json.dumps(data))
        else:
            data = {
                'code': '200',
                'message': 'Success',
                'user_info': {
                    'user_id': user_id,
                    'account': account,
                    'password': password,
                    'gender': gender,
                    'birthday': birthday,
                    'height': height,
                    'weight': weight
                }
            }

            self.write(json.dumps(data))