17 lines
335 B
Python
17 lines
335 B
Python
import requests
|
|
|
|
def ping(url: str) -> int:
|
|
"""
|
|
Makes a GET request to the given website and returns the HTTP status code or -1 in case of failure
|
|
:param url: The URL of the website to ping
|
|
:return: The HTTP status code
|
|
"""
|
|
try:
|
|
res = requests.get(url)
|
|
except:
|
|
return -1
|
|
|
|
if res:
|
|
return res.status_code
|
|
else:
|
|
return -1 |