Python Forum
How can I check out my localhost?
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I check out my localhost?
#1
I am using a libre requests. I am trying to check out localhost and if it is working then to type the message "Yes". If it isn't working then to type the message "No". Now my localhost is working and after I run my script I get the message "Yest" and it is normally. But when my localhost isn't working I don't get the message "No" . I only get a stack of errors.
Here is my code:


import requests

url = 'http://localhost:8000'
response = requests.get(url)
if response.status_code == 200:
    print("Yes ...")
else:
    print("No ...")
Why doesn't it type the message "No" when the localhost isn't working ?
Reply


Messages In This Thread
How can I check out my localhost? - by Mike Ru - Aug-04-2017, 09:01 PM
RE: How can I check out my localhost? - by buran - Aug-05-2017, 05:21 AM
RE: How can I check out my localhost? - by Mike Ru - Aug-05-2017, 05:50 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020