import pytz


def get_country_code(request):
    """
    Country code based on ISO 3166-1 (http://en.wikipedia.org/wiki/ISO_3166-1)
    :param request: Request Object
    :return: ISO Code of the country
    """
    if 'X-AppEngine-Country' in request.headers:
        if request.headers['X-AppEngine-Country'] in pytz.country_timezones:
            return request.headers['X-AppEngine-Country']
    return None