Custom Tools
Testing code blocks and other various elements as I build out these initial entries. I don’t consider myself a ‘programmer’ by any means but I do a pretty good job figuring out answers to questions that arise during my various coding projects.
There will be random updates to posts as I have limited cycles available and I wanted to go ahead and get the site live for other testing.
Below is a simple python script for checking your site status…
import requests
def check_website_status(url):
"""Checks the status of a given URL and prints the result."""
try:
# Send a GET request to the URL
response = requests.get(url, timeout=10) # Added a timeout for better practice
# Check the HTTP status code
if response.status_code == 200:
print(f"-o- Success: {url} is **UP** (HTTP Status: {response.status_code})")
elif 300 <= response.status_code < 400:
print(f"-!- Warning: {url} is redirecting (HTTP Status: {response.status_code})")
elif 400 <= response.status_code < 500:
print(f"-X- Error: {url} returned a Client Error (HTTP Status: {response.status_code})")
elif 500 <= response.status_code < 600:
print(f"-X- Error: {url} returned a Server Error (HTTP Status: {response.status_code})")
else:
print(f"-?- Unknown Status: {url} returned an unusual status code ({response.status_code})")
except requests.exceptions.Timeout:
print(f"-%- Timeout Error: Request to {url} timed out.")
except requests.exceptions.ConnectionError:
print(f"-%- Connection Error: Could not connect to {url}.")
except requests.exceptions.RequestException as e:
# Catch all other possible errors (e.g., DNS error, too many redirects)
print(f"-%- An unexpected error occurred with {url}: {e}")
# --- Configuration ---
target_url = "https://pivoted.io" # Update to your valid url
# ---------------------
check_website_status(target_url)
Test with your own URL!
(more updates coming)