restful_api.py
def convert_data(json_data):
    """
    This converts a json string into a dictionary to process later.

    Args:
        json_data: This is data it accepts in a json format
        an example [{'num_1': 2, 'num_2': 3, 'operation': 'add'}]

    Returns:
        This returns a dictionary with keys:
            num_1: The first number which the program program should apply the operation to
            num_2: The second number the program uses to apply the operation to
            operation: This is the mathematical operation that is used to apply to the numbers given

    Raises:
        KeyError:
            if JSON does not contain the required keys it returns with a json 'message':
            'the json does not contain required fields in the specified format, namely'
            if JSON does not have values stored in the correct
            format for num_1, num_2 or, operation,
            the program returns with a json
             'message': 'could not read in data properly'
    """
    keylist = []
    data = json_data
    dictionary = []
    required_keys = ['num_1', 'num_2', 'operation']
    for key in data[0]:
        keylist.append(key)
    if not verify_list(keylist, required_keys):
        return {'message':
                    'the json does not contain required fields in the spesified format, namely '
                    + str(required_keys)
                }
    try:
        for datapoint in data:
            dictionary.append(
                {'num_1': datapoint['num_1'],
                 'num_2': datapoint['num_2'],
                 'operation': datapoint['operation']})
        return dictionary
    except IndexError:
        return {'message': 'could not read in data properly'}

    This converts a json string into a dictionary to process later.

    Args:
        json_data: This is data it accepts in a json format
        an example [{'num_1': 2, 'num_2': 3, 'operation': 'add'}]

    Returns:
        This returns a dictionary with keys:
            num_1: The first number which the program program should apply the operation to
            num_2: The second number the program uses to apply the operation to
            operation: This is the mathematical operation that is used to apply to the numbers given

    Raises:
        KeyError:
            if JSON does not contain the required keys it returns with a json 'message':
            'the json does not contain required fields in the specified format, namely'
            if JSON does not have values stored in the correct
            format for num_1, num_2 or, operation,
            the program returns with a json
             'message': 'could not read in data properly'
    
This converts a json string into a dictionary to process later.
This converts a json string into a dictionary to process later .
def convert_data(json_data):
    keylist = []
    data = json_data
    dictionary = []
    required_keys = ['num_1', 'num_2', 'operation']
    for key in data[0]:
        keylist.append(key)
    if not verify_list(keylist, required_keys):
        return {'message':
                    'the json does not contain required fields in the spesified format, namely '
                    + str(required_keys)
                }
    try:
        for datapoint in data:
            dictionary.append(
                {'num_1': datapoint['num_1'],
                 'num_2': datapoint['num_2'],
                 'operation': datapoint['operation']})
        return dictionary
    except IndexError:
        return {'message': 'could not read in data properly'}
def convert_data ( json_data ) : keylist = [ ] data = json_data dictionary = [ ] required_keys = [ 'num_1' , 'num_2' , 'operation' ] for key in data [ 0 ] : keylist . append ( key ) if not verify_list ( keylist , required_keys ) : return { 'message' : 'the json does not contain required fields in the spesified format, namely ' + str ( required_keys ) } try : for datapoint in data : dictionary . append ( { 'num_1' : datapoint [ 'num_1' ] , 'num_2' : datapoint [ 'num_2' ] , 'operation' : datapoint [ 'operation' ] } ) return dictionary except IndexError : return { 'message' : 'could not read in data properly' }
This converts a json string into a dictionary to process later.
This converts a json string into a dictionary to process later .
"""
    This converts a json string into a dictionary to process later.

    Args:
        json_data: This is data it accepts in a json format
        an example [{'num_1': 2, 'num_2': 3, 'operation': 'add'}]

    Returns:
        This returns a dictionary with keys:
            num_1: The first number which the program program should apply the operation to
            num_2: The second number the program uses to apply the operation to
            operation: This is the mathematical operation that is used to apply to the numbers given

    Raises:
        KeyError:
            if JSON does not contain the required keys it returns with a json 'message':
            'the json does not contain required fields in the specified format, namely'
            if JSON does not have values stored in the correct
            format for num_1, num_2 or, operation,
            the program returns with a json
             'message': 'could not read in data properly'
    """
This returns a dictionary with keys:
num_1: The first number which the program program should apply the operation to
num_2: The second number the program uses to apply the operation to
operation: This is the mathematical operation that is used to apply to the numbers given
This returns a dictionary with keys : num_1 : The first number which the program program should apply the operation to num_2 : The second number the program uses to apply the operation to operation : This is the mathematical operation that is used to apply to the numbers given
if JSON does not contain the required keys it returns with a json 'message':
'the json does not contain required fields in the specified format, namely'
if JSON does not have values stored in the correct
format for num_1, num_2 or, operation,
the program returns with a json
'message': 'could not read in data properly'
if JSON does not contain the required keys it returns with a json ' message ' : ' the json does not contain required fields in the specified format namely ' if JSON does not have values stored in the correct format for num_1 num_2 or operation the program returns with a json ' message ' : ' could not read in data properly '
KeyError
json_data
This is data it accepts in a json format
This is data it accepts in a json format
an example [{'num_1'
None