Skip to content

Commit

Permalink
Add check script for ch06s06 (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
jramcast authored Nov 27, 2020
1 parent d958439 commit 32ac625
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tools/check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python

import sys
import time
import logging
import urllib.request


logging.basicConfig(
format='%(asctime)s %(levelname)-8s %(message)s',
level=logging.INFO,
datefmt='%Y-%m-%d %H:%M:%S')


def request(url):
try:
response = urllib.request.urlopen(url)
logging.info(response.read().decode())
except urllib.error.HTTPError as error:
logging.error(error)


if len(sys.argv) < 2:
print("Please specify URL")
print(" EXAMPLE: check.py http://your/url")
exit(1)


URL = sys.argv[1]
print("Checking {}\n".format(URL))

while True:
request(URL)
time.sleep(1)

0 comments on commit 32ac625

Please sign in to comment.