import requests
import shutil


def send_request_to_api(request, token):
    """ Sends a GET request to WolframAlpha API and saves the file as a .gif. """
    url = "http://api.wolframalpha.com/v1/simple?appid=" + token + "&i=" + request + "&width=1000"
    response = requests.get(url, stream=True)
    if response.ok:
        with open("request.gif", "wb") as out_file:
            shutil.copyfileobj(response.raw, out_file)
    return response.status_code