Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ServerChecker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Description
The script can be used to check if a certain server is up or not.

## Steps for Execution
1. Fork this repository
2. Find the serverCheck.py file and run it.
3. Enter the website's name you would like to check.
4. If you would like to go again answer with 'Y', otherwise write 'N'
23 changes: 23 additions & 0 deletions ServerChecker/serverChecker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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