def test_extract_links(self): links = extract_links("https://www.docker.com") self.assertIn( { 'text': 'Why Docker?', 'href': 'https://www.docker.com/why-docker' }, links) print('\t The extract_links function is working correctly')
def api(url): qs = request.query_string.decode("utf-8") if qs != "": url += "?" + qs jsonlinks = redis_conn.get(url) if not jsonlinks: links = extract_links(url) jsonlinks = json.dumps(links, indent=2) redis_conn.set(url, jsonlinks) response = app.response_class(status=200, mimetype="application/json", response=jsonlinks) return response
def api(url): qs = request.query_string.decode("utf-8") if qs != "": url += "?" + qs links = extract_links(url) return jsonify(links)