Esempio n. 1
0
def one_continent():
    continents_data = utils.read_json("continents_data")
    query_parameters = request.args
    name = query_parameters.get('name')
    id = query_parameters.get('id')
    if name:
        continent = [
            continent for continent in continents_data[1:]
            if continent["Continent"] == name
        ]
        return jsonify(continent)
    if id:
        continent = [
            continent for continent in continents_data[1:]
            if continent["Id"] == int(id)
        ]
        return jsonify(continent)
Esempio n. 2
0
def one_country():
    countries_data = utils.read_json("countries_data")
    query_parameters = request.args
    id = query_parameters.get('id')
    continent = query_parameters.get('continent')
    name = query_parameters.get('name')
    if id:
        country = [
            country for country in countries_data[1:]
            if country["Id"] == str(id)
        ]
        return jsonify(country)
    if continent:
        country = [
            country for country in countries_data[1:]
            if country["InContinent"] == continent
        ]
        return jsonify(country)
    if name:
        country = [
            country for country in countries_data[1:]
            if country["Country"] == name
        ]
        return jsonify(country)
Esempio n. 3
0
def all_continents():
    continents_data = utils.read_json("continents_data")
    return jsonify(continents_data)
Esempio n. 4
0
def all_countries():
    return jsonify(utils.read_json("countries_data"))
Esempio n. 5
0
def total():
    return jsonify(utils.read_json("total_data"))