File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ import os
2+ import requests
3+
4+ def restart ():
5+ answer = str (input ("Do you want to start over? y/n " )).lower ()
6+ if answer == "y" or answer == "n" :
7+ if answer == "y" :
8+ main ()
9+ else :
10+ print ("OK. Bye!" )
11+ return
12+ else :
13+ print ("That's not a valid answer. Please answer `y` or `n`" )
14+ restart ()
15+
16+
17+ def main ():
18+ os .system ("clear" )
19+ print ("Welcome to IsItDown.py!\n Please write a URL or URLs you want to check. (separated by comma)" )
20+ URLs = str (input ()).lower ().split ("," )
21+ for URL in URLs :
22+ URL = URL .strip ()
23+ if "." not in URL :
24+ print (URL , "is not a valid URL." )
25+ else :
26+ if "http" not in URL :
27+ URL = f"http://{ URL } "
28+ try :
29+ request = requests .get (URL )
30+ if request .status_code == 200 :
31+ print (URL , "is up!" )
32+ else :
33+ print (URL , "is down!" )
34+ except :
35+ print (URL , "is down!" )
36+ restart ()
37+
38+ main ()
You can’t perform that action at this time.
0 commit comments