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)
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)
def all_continents(): continents_data = utils.read_json("continents_data") return jsonify(continents_data)
def all_countries(): return jsonify(utils.read_json("countries_data"))
def total(): return jsonify(utils.read_json("total_data"))