Files
Django_kube/django_code/apps/streaming/utils.py
T
2026-08-05 14:34:06 +01:00

33 lines
860 B
Python

import requests
from django.conf import settings
def full_testing(url_website):
status = "unknown"
#step 1 : test without VPN
status = test_website(url_website)
#step 2 : test with VPN
#if status != 200:
# status = test_website(url_website,bool_proxy=True)
return status
def test_website(url_website,bool_proxy=False):
try:
if bool_proxy:
status = requests.get(url_website,proxies=settings.PROXIES)
else:
status = requests.get(url_website).status_code
except requests.exceptions.ConnectionError:
status = "ConnectionError"
#identify the exception name
except Exception as err:
print(f"{type(err).__name__} was raised: {err}")
status = "exception not targeted"
return status