Skip to content

Commit 05f3793

Browse files
committed
Adding serverChecker.py
Also adding a README.md file attached
1 parent 92a582e commit 05f3793

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

ServerChecker/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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'

ServerChecker/serverChecker.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy