コード例 #1
0
def create_user():
    try:
        logger.info(f'Creating user for request {request.json}')
        user = User.from_dict(request.json)
    except (KeyError, TypeError):
        logger.exception('Error creating user')
        return jsonify({'error': 'Please provide at least a valid id'
                        }), http.HTTPStatus.BAD_REQUEST
    users_dynamodb.add_user(user)
    return jsonify(user)
コード例 #2
0
def update_user(user_id):
    logger.info(f'Updating user id {user_id} for request {request.json}')
    request.json['id'] = user_id
    try:
        user = User.from_dict(request.json)
    except (KeyError, TypeError):
        logger.exception('Error updating user')
        return jsonify({'error': 'Please provide at least a valid id'
                        }), http.HTTPStatus.BAD_REQUEST
    users_dynamodb.add_user(user)
    return jsonify(user)