import requests

response = requests.get("http://httpbin.org/get", timeout = 5)
print("Kod stanu: " + str(response.status_code))
print(response.headers)
if response.status_code == 200:
    results = response.json()
    for result in results.items():
        print(result)
    print("Nagłówki odpowiedzi:")
    for header, value in response.headers.items():
        print(header, '-->', value)
    print("Nagłówki zapytania:")
    for header, value in response.request.headers.items():
        print(header, '-->', value)
    print("Serwer:" + response.headers['server'])
else:
    print("Kod błędu: %s" % response.status_code)