File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ # Description
2+ This returns whether or not a connecion to a given server could be established.
3+
4+ ## Steps for Execution
5+ 1 . Fork this repository
6+ 2 . Find the serverCheck.py file and run it.
7+ 3 . Enter the website's name you would like to check.
8+ 4 . If you would like to go again answer with 'Y', otherwise write 'N'
Original file line number Diff line number Diff line change 1+ import socket
2+
3+ def is_running (site ):
4+ """This function attempts to connect to the given server using a socket.
5+ Returns: Whether or not it was able to connect to the server."""
6+ try :
7+ sock = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
8+ sock .connect ((site , 80 ))
9+ return True
10+ except :
11+ return False
12+
13+ if __name__ == "__main__" :
14+ while True :
15+ site = input ('Website to check: ' )
16+ if is_running (f'{ site } .com' ):
17+ print (f"{ site } .com is running!" )
18+ else :
19+ print (f'There is a problem with { site } .com!' )
20+
21+ if input ("Would You like to check another website(Y/N)? " ) in {'n' , 'N' }:
22+ break
You can’t perform that action at this time.
0 commit comments