We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 806f49c commit 32cd700Copy full SHA for 32cd700
projects/Internet_connection_check/internet_connection_check.py
@@ -1,16 +1,23 @@
1
import requests
2
+from requests.exceptions import ConnectionError
3
4
def internet_connection_test():
5
url = 'https://www.google.com/'
6
print(f'Attempting to connect to {url} to determine internet connection status.')
7
8
try:
- requests.get(url, timeout = 10)
9
+ print(url)
10
+ resp = requests.get(url, timeout = 10)
11
+ resp.text
12
+ resp.status_code
13
print(f'Connection to {url} was successful.')
14
return True
- except:
15
+ except ConnectionError as e:
16
requests.ConnectionError
17
print(f'Failed to connect to {url}.')
18
return False
-
19
+ except:
20
+ print(f'Failed with unparsed reason.')
21
+ return False
22
+
23
internet_connection_test()
0 commit comments