I am working with a while loop which I am trying to run for 5 minutes and check if it gets the http response code 200. The problem is if it doesn't get 200 it will be keep running, but it doesn't go to the else when the site should be up and running.
r = requests.head("http://www.testing.co.uk")
while r.status_code != 200:
print "Response not == to 200."
time.sleep(30)
else:
print "Response is 200 - OK"
status_codewill not change unless you repeat the request!while count < 5:thancount -=instead of calling it infinitely.