Exemplo n.º 1
0
def main():
    print('List of tuples')
    resp = yield from aiorequests.get('http://httpbin.org/get',
                                      params=[('foo', 'bar'), ('baz', 'bax')])
    content = yield from resp.text()
    print(content)

    print('Single value dictionary')
    resp = yield from aiorequests.get('http://httpbin.org/get',
                          params={'foo': 'bar', 'baz': 'bax'})
    content = yield from resp.text()
    print(content)

    print('Multi value dictionary')
    resp = yield from aiorequests.get('http://httpbin.org/get',
                          params={'foo': ['bar', 'baz', 'bax']})
    content = yield from resp.text()
    print(content)

    print('Mixed value dictionary')
    resp = yield from aiorequests.get('http://httpbin.org/get',
                          params={'foo': ['bar', 'baz'], 'bax': 'quux'})
    content = yield from resp.text()
    print(content)

    print('Preserved query parameters')
    resp = yield from aiorequests.get('http://httpbin.org/get?foo=bar',
                          params={'baz': 'bax'})
    content = yield from resp.text()
    print(content)
Exemplo n.º 2
0
def main(*args):
    r = yield from aiorequests.get('http://httpbin.org/get')
    print((yield from r.text()))
Exemplo n.º 3
0
def download_file(*args):
    url, destination_filename = 'http://httpbin.org/get', 'download.txt'
    destination = open(destination_filename, 'wb')
    r = yield from aiorequests.get(url)
    destination.write((yield from r.text()))
    destination.close()
Exemplo n.º 4
0
def main(*args):
    r = yield from aiorequests.get(
        'http://httpbin.org/basic-auth/treq/treq',
        auth=('treq', 'treq')
    )
    print((yield from r.text()))
Exemplo n.º 5
0
def download_file(*args):
    url, destination_filename = 'http://httpbin.org/get', 'download.txt'
    destination = open(destination_filename, 'wb')
    r = yield from aiorequests.get(url)
    destination.write((yield from r.text()))
    destination.close()
Exemplo n.º 6
0
def main(*args):
    r = yield from aiorequests.get('http://httpbin.org/get')
    print((yield from r.text()))
Exemplo n.º 7
0
def main(*args):
    resp = yield from aiorequests.get('http://httpbin.org/redirect/1')
    print(resp.original.status)
Exemplo n.º 8
0
def main(*args):
    r = yield from aiorequests.get('http://httpbin.org/redirect/1',
                                   allow_redirects=False)
    print(r.original.status)