Exemplo n.º 1
0
def search():
    search_term = request.args.get('term')
    gif_url = url_builders.build_gif_url(search_term)
    response = requests.get(gif_url)
    data = json.loads(response.content)
    gify_url = data['data']['fixed_height_downsampled_url']
    json_url = {"url": gify_url}

    return jsonify(json_url)
Exemplo n.º 2
0
 def test_build_gif_url_with_a_search_term(self):
     self.assertEqual(url_builders.build_gif_url("fun"),
                      'http://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC&tag=fun')
Exemplo n.º 3
0
 def test_build_gif_url_when_there_is_no_search_term(self):
     self.assertEqual(url_builders.build_gif_url(None),
                      'http://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC')