def test_wiki(): response = external._lookup_wikipedia("New York", country_name = "United States") assert(response[1][1] == "New York City") # test_wiki 1 response = external._lookup_wikipedia("New York", country_name = False) assert(response[1][1] == "New York City") # test_wiki 2 response = external._lookup_wikipedia("Boston", country_name = "United States") assert(response[1][0] == "Boston") # test_wiki 3
def get_city_description(city_name, country_name): if city_name in _known_result_indices: articles = external._lookup_wikipedia(city_name) index = _known_result_indices[city_name] else: articles = external._lookup_wikipedia(city_name, country_name) index = 0 # use first result return {"title": articles[1][index], "text": articles[2][index], "url": articles[3][index]}
def wiki_json(): city_name = request.args.get('city') country_name = request.args.get('country') result = external._lookup_wikipedia(city_name, country_name) return jsonify({'wiki-json': result})
def get_wikipedia_json(self): if self._wiki_json is None: self._wiki_json = external._lookup_wikipedia(self.name) return self._wiki_json
def wiki_json(): city_name = request.args.get('city') country_name = request.args.get('country') result = external._lookup_wikipedia(city_name) # generates multiple articles return jsonify({'wiki-json': result})