301 от GitHub-запроса от usocket micropython

    **i am getting 301 from my github repo when trying to get one json file 
    useing micropython usocket**

        b'HTTP/1.1 301 Moved Permanently\r\nServer: Varnish\r\nRetry-After: 0\r\nLocation: https://raw.githubuserc
    ontent.com/pawansankhle/my-iot/master/dev/esp8266_525a8a00/update.json\r\nContent-Length: 0\r\nAccept-Rang
    es: bytes\r\nDate: Sat, 10 Feb 2018 14:09:45 GMT\r\nVia: 1.1 varnish\r\nConnection: close\r\nX-Served-By:
    cache-ams4449-AMS\r\nX-Cache: HIT\r\nX-Cache-Hits: 0\r\nX-Timer: S1518271785.251491,VS0,VE0\r\nAccess-Cont
    rol-Allow-Origin: *\r\nExpires: Sat, 10 Feb 2018 14:14:45 GMT\r\nVary: Authorization,Accept-Encoding\r\n\r\n'

**this is response i am getting from github and my code is**

def start(url='https://github.com/pawansankhle/my-iot/raw/master/dev/'+ _config.get_client_id() +'/update.json'):
    try:
        import ujson as json
        print(url)
        res = http_get(url)
        print(res)
        response = json.loads(res)
        print(response)
        for file in response['files']:
            path = file['path']
            url = 'https://raw.githubusercontent.com/pawansankhle/my-iot/master/dev/{}'.format(path)
            http_get_to_file(url, path)
    except Exception as ex:
            print(ex)

и это мой метод http_get, чтобы получить реальные данные

def http_get(url): response = b'' try: get = http_get_async(url), в то время как True: file_bytes = get.send(None) ответ += file_bytes, кроме StopIteration: pass

response_str = str(response, 'utf-8')
return response_str

0 ответов

Другие вопросы по тегам