-
Notifications
You must be signed in to change notification settings - Fork 0
/
connection_error.py
41 lines (32 loc) · 1.15 KB
/
connection_error.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Built-in libraries
import webbrowser
import time
def main(
error_code: int,
file_name: str
) -> None:
"""
Function to handle connection_errors
Args:
error_code (int): Error code received by response
file_name (str): File name in which the error occurred
"""
print(f"Response came back with status code {error_code} with {file_name}")
# While loop to ask if the user wants to look up the error code
while True:
user_input = input(
f"Would you like to look up status code {error_code}? (Y/N) "
)
user_input.lower()
if user_input == "y" or user_input == "yes" or user_input == "1":
print("Your browser will pull up a wikipedia article.")
time.sleep(2)
webbrowser.open("https://en.wikipedia.org/wiki/List_of_HTTP_status_codes")
break
elif user_input == "n" or user_input == "no" or user_input == "0":
break
else:
print("Invalid input")
# If the program is run directly when it is not supposed to
if __name__ == "__main__":
print("This file is not supposed to be run by itself.")