Exemplo n.º 1
0
def get_schedule():
    try:
        args = request.args.to_dict()
        query = url_query_builder(URL + args)
        r = requests.get(url=query)
    except HTTPError as http_err:
        print(f'HTTP error occurred: {http_err}')
    except Exception as err:
        print(f'Other error occurred: {err}')
    else:
        res = json.loads(r.content)
        return {'schedule': res, 'status_code': r.status_code}
Exemplo n.º 2
0
def get_team(team_id):
    try:
        args = request.args.to_dict()
        query = url_query_builder(args)
        r = requests.get(url=URL + '/' + team_id + query)
    except HTTPError as http_err:
        print(f'HTTP error occurred: {http_err}')
    except Exception as err:
        print(f'Other error occurred: {err}')
    else:
        res = json.loads(r.content)
        return {'team': res['teams'][0], 'status_code': r.status_code}
Exemplo n.º 3
0
def get_player_stats(player_id):
    try:
        args = request.args.to_dict()
        query = url_query_builder(args)
        r = requests.get(url=PLAYER_STATS_URL + '/' + player_id + '/stats' + query)
    except HTTPError as http_err:
        print(f'HTTP error occurred: {http_err}')
    except Exception as err:
        print(f'Other error occurred: {err}')
    else:
        res = json.loads(r.content)
        return {
            'stats': res,
            'status_code': r.status_code
        }