Example #1
0
def verify_token(token, password):
    try:
        if not token or not SecurityController.auth_user(token):
            return False
        return True 
    except Exception as e:
        abort(ErrorController.handle_errors(e))
Example #2
0
def get_typesof_columns(table_name):
    '''Returns data types for any table available via the API
    Current tables available: User'''
    try:
        return Response(DataController.get_typesof_columns(table_name), 
            mimetype='application/json')
    except Exception as e:
        abort(ErrorController.handle_errors(e))
Example #3
0
def generate_auth_token(username, password):
    '''Route to generate a token
    
    Returns the token that must be sent in the header as the username
    with 'unused' as the password. All routes that contain data 
    require the token.
    
    Token expires in 20 minutes of issuance
    
    Example:
    curl -i -X GET -H "Content-Type: application/json" 
    https://localhost/token/username/password
    '''
    try:
        return SecurityController.generate_auth_token(username, password)
    except Exception as e:
        abort(ErrorController.handle_errors(e))
Example #4
0
def total_cost():
    '''
    Caclulcates the total cost, principle and interest, for a loan

    Required payload is json stucture like the following:
    { "loan_terms":
        {
            "apr":0.04
            , "years":5
            , "amount":10000
        }
    }
    '''
    try:
        loan_terms = request.json.get('loan_terms')
        return LoanController.get_total_cost(loan_terms)
    except Exception as e:
        abort(ErrorController.handle_errors(e))
Example #5
0
def monthly_payment():
    '''
    Caclulcates the monthly payment for a loan

    Required payload is json stucture like the following:
    { "loan_terms":
        {
            "apr":0.04
            , "years":5
            , "amount":10000
        }
    }
    '''
    try:
        loan_terms = request.json.get('loan_terms')
        return LoanController.get_monthly_payment(loan_terms)
    except Exception as e:
        abort(ErrorController.handle_errors(e))
Example #6
0
def ping():
    '''Route to ping server'''
    try: 
        return PingController.get_ping_json()
    except Exception as e:
        abort(ErrorController.handle_errors(e))
Example #7
0
def doc_private():
    '''Returns all private routes and descriptions'''
    try:
        return auto.html('private')
    except Exception as e:
        abort(ErrorController.handle_errors(e))