forked from larymak/Python-project-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverChecker.py
More file actions
23 lines (19 loc) · 704 Bytes
/
serverChecker.py
File metadata and controls
23 lines (19 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import socket
def is_running(site):
"""This function attempts to connect to the given server using a socket.
Returns: Whether or not it was able to connect to the server."""
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((site, 80))
return True
except:
return False
if __name__ == "__main__":
while True:
site = input('Website to check: ')
if is_running(f'{site}.com'):
print(f"{site}.com is running!")
else:
print(f'There is a problem with {site}.com!')
if input("Would You like to check another website(Y/N)? ") in {'n', 'N'}:
break