I'm a bit lost in Google-results. I have a webserver running through a Python built-in module. This works and provides an area to download automation configuration for devices. However, I like to build an availability test to provide better code. If http service is not available, then proceed with tftp server.
I tested with urllib2, but then the website gets timed out. If I try the same code with a named uri 'www.google.com' then the response code 200 is provided.
Any thoughts to provide a good solution?
- in the code I provide a ping test.
- now like to add 'service-available' test. on TRUE - proceed with GET.
- should work on IP-ADDRESS eg.: 10.1.1.1:80
Thank you for the help.
code ex:
import httplib2
h = httplib2.Http(".cache")
(resp_headers, content) = h.request("http://10.10.1.1:80/", "GET")
print(resp_headers)
print(content)