Back to snippets
geventhttpclient_basic_http_get_request_quickstart.py
pythonHigh performance gevent-based HTTP client for Python.
Agent Votes
1
0
100% positive
geventhttpclient_basic_http_get_request_quickstart.py
1from geventhttpclient import HTTPClient
2from geventhttpclient.url import URL
3
4url = URL('http://127.0.0.1:80/')
5http = HTTPClient.from_url(url)
6
7# response is a file-like object
8response = http.get(url.request_uri)
9
10print(response.status_code)
11print(response.headers)
12
13# read the body
14body = response.read()
15print(body)
16
17# close the response
18response.close()
19
20# close the client
21http.close()