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))
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))
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))
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))
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))
def ping(): '''Route to ping server''' try: return PingController.get_ping_json() except Exception as e: abort(ErrorController.handle_errors(e))
def doc_private(): '''Returns all private routes and descriptions''' try: return auto.html('private') except Exception as e: abort(ErrorController.handle_errors(e))