Exemplo n.º 1
0
def add_user():
    request_data = request.get_json()
    try:
        jsonschema.validate(request_data, add_user_schema)
        User.add_user(request_data['username'], request_data['email'])
        response = Response(json.dumps(request_data),
                            201,
                            mimetype="application/json")
        response.headers['Location'] = "users/v1/" + str(
            request_data['username'])
    except jsonschema.exceptions.ValidationError as exc:
        response = Response(error_message_helper(exc.message),
                            400,
                            mimetype="application/json")
    return response