Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnny111125 authored Dec 25, 2022
1 parent 49e2704 commit aecea71
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions HTTP(S) Endpoint Monitor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import re
import requests
import time

def print_green(text):
print(f"\033[92m{text}\033[0m")

def print_red(text):
print(f"\033[91m{text}\033[0m")

def check_endpoint(endpoint, pattern):
try:
r = requests.get(endpoint)
if r.status_code == 200:
if re.search(pattern, r.text):
print_green(f"{endpoint} is up and the pattern was found")
else:
print_red(f"{endpoint} is up but the pattern was not found")
else:
print_red(f"{endpoint} is down")
except:
print_red(f"{endpoint} is down")

endpoints = ["http://example.com", "http://example.org", "http://example.net"]
pattern = input("Enter the pattern to search for: ")

while True:
for endpoint in endpoints:
check_endpoint(endpoint, pattern)
time.sleep(60)

0 comments on commit aecea71

Please sign in to comment.