ServerDowntimeNotifier/WebsitePingService.py
2021-03-10 22:07:52 +01:00

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