restful_api.py
def post(self):
        '''
        The default flask required format, communicates with requests
        and returns the result of the processing in a json format
        Args:
            Resources from the URL request
        Returns:
            JSON with the function processed with the basic_math module,
            along with a success code (or a message specifying why it could not be processed)
        '''
        json_format = request.get_json()
        converted_format = convert_data(json_format)
        result = []
        functions = {'add': basic_math.adding,
                     'subtract': basic_math.subtraction,
                     'multiplication': basic_math.multiplication,
                     'integer_divide': basic_math.integer_divide,
                     'remainder': basic_math.remainder,
                     'power': basic_math.power,
                     'root': basic_math.root}
        for datapoint in converted_format:
          # todo remove old code
            '''#original fixed to new function for better styling
          if(datapoint['operation']=='add'):
              result.append(BasicMath.adding(datapoint['num_1'],datapoint['num_2']))
          elif(datapoint['operation']=='subtract'):
              result.append(BasicMath.subtraction(datapoint['num_1'],datapoint['num_2']))
          elif(datapoint['operation']=='multiplication'):
              result.append(BasicMath.multiplication(datapoint['num_1'],datapoint['num_2']))
          elif(datapoint['operation']=='integer_divide'):
              result.append(BasicMath.integer_divide(datapoint['num_1'],datapoint['num_2']))
          elif(datapoint['operation']=='remainder'):
              result.append(BasicMath.remainder(datapoint['num_1'],datapoint['num_2']))
          elif(datapoint['operation']=='power'):
              result.append(BasicMath.power(datapoint['num_1'],datapoint['num_2']))
          elif(datapoint['operation']=='root'):
              result.append(BasicMath.root(datapoint['num_1'],datapoint['num_2']))'''
            try:
                result.append(
                    functions[datapoint['operation']]
                    (datapoint['num_1'], datapoint['num_2'])
                )
            except IndexError:
                result.append('operation not supported')

        return result, 201

        The default flask required format, communicates with requests
        and returns the result of the processing in a json format
        Args:
            Resources from the URL request
        Returns:
            JSON with the function processed with the basic_math module,
            along with a success code (or a message specifying why it could not be processed)
        
The default flask required format, communicates with requests
and returns the result of the processing in a json format
Args:
Resources from the URL request
Returns:
JSON with the function processed with the basic_math module,
along with a success code (or a message specifying why it could not be processed)
The default flask required format communicates with requests and returns the result of the processing in a json format Args : Resources from the URL request Returns : JSON with the function processed with the basic_math module along with a success code ( or a message specifying why it could not be processed )
def post(self):
        json_format = request.get_json()
        converted_format = convert_data(json_format)
        result = []
        functions = {'add': basic_math.adding,
                     'subtract': basic_math.subtraction,
                     'multiplication': basic_math.multiplication,
                     'integer_divide': basic_math.integer_divide,
                     'remainder': basic_math.remainder,
                     'power': basic_math.power,
                     'root': basic_math.root}
        for datapoint in converted_format:
            try:
                result.append(
                    functions[datapoint['operation']]
                    (datapoint['num_1'], datapoint['num_2'])
                )
            except IndexError:
                result.append('operation not supported')
        return result, 201
def post ( self ) : json_format = request . get_json ( ) converted_format = convert_data ( json_format ) result = [ ] functions = { 'add' : basic_math . adding , 'subtract' : basic_math . subtraction , 'multiplication' : basic_math . multiplication , 'integer_divide' : basic_math . integer_divide , 'remainder' : basic_math . remainder , 'power' : basic_math . power , 'root' : basic_math . root } for datapoint in converted_format : '''#original fixed to new function for better styling
          if(datapoint['operation']=='add'):
              result.append(BasicMath.adding(datapoint['num_1'],datapoint['num_2']))
          elif(datapoint['operation']=='subtract'):
              result.append(BasicMath.subtraction(datapoint['num_1'],datapoint['num_2']))
          elif(datapoint['operation']=='multiplication'):
              result.append(BasicMath.multiplication(datapoint['num_1'],datapoint['num_2']))
          elif(datapoint['operation']=='integer_divide'):
              result.append(BasicMath.integer_divide(datapoint['num_1'],datapoint['num_2']))
          elif(datapoint['operation']=='remainder'):
              result.append(BasicMath.remainder(datapoint['num_1'],datapoint['num_2']))
          elif(datapoint['operation']=='power'):
              result.append(BasicMath.power(datapoint['num_1'],datapoint['num_2']))
          elif(datapoint['operation']=='root'):
              result.append(BasicMath.root(datapoint['num_1'],datapoint['num_2']))''' try : result . append ( functions [ datapoint [ 'operation' ] ] ( datapoint [ 'num_1' ] , datapoint [ 'num_2' ] ) ) except IndexError : result . append ( 'operation not supported' ) return result , 201
The default flask required format, communicates with requests
and returns the result of the processing in a json format
Args:
Resources from the URL request
Returns:
JSON with the function processed with the basic_math module,
along with a success code (or a message specifying why it could not be processed)
The default flask required format communicates with requests and returns the result of the processing in a json format Args : Resources from the URL request Returns : JSON with the function processed with the basic_math module along with a success code ( or a message specifying why it could not be processed )
'''
        The default flask required format, communicates with requests
        and returns the result of the processing in a json format
        Args:
            Resources from the URL request
        Returns:
            JSON with the function processed with the basic_math module,
            along with a success code (or a message specifying why it could not be processed)
        ''' # todo remove old code '''#original fixed to new function for better styling
          if(datapoint['operation']=='add'):
              result.append(BasicMath.adding(datapoint['num_1'],datapoint['num_2']))
          elif(datapoint['operation']=='subtract'):
              result.append(BasicMath.subtraction(datapoint['num_1'],datapoint['num_2']))
          elif(datapoint['operation']=='multiplication'):
              result.append(BasicMath.multiplication(datapoint['num_1'],datapoint['num_2']))
          elif(datapoint['operation']=='integer_divide'):
              result.append(BasicMath.integer_divide(datapoint['num_1'],datapoint['num_2']))
          elif(datapoint['operation']=='remainder'):
              result.append(BasicMath.remainder(datapoint['num_1'],datapoint['num_2']))
          elif(datapoint['operation']=='power'):
              result.append(BasicMath.power(datapoint['num_1'],datapoint['num_2']))
          elif(datapoint['operation']=='root'):
              result.append(BasicMath.root(datapoint['num_1'],datapoint['num_2']))'''
self