Created
January 20, 2018 10:52
-
-
Save elliotforbes/3be76d4435d191ef7474aeb22ddef9a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import urllib.request | |
| import os | |
| import time | |
| def lambda_handler(event, context): | |
| request = urllib.request.Request(event['Url']) | |
| try: | |
| start_time = time.time() | |
| urllib.request.urlopen(request) | |
| end_time = time.time() | |
| total_time = end_time - start_time | |
| except urllib.error.HTTPError as e: | |
| print(e.code) | |
| print(e.read()) | |
| return str(e) | |
| else: | |
| print("{} Was Loaded in {}!".format(event['Url'], total_time)) | |
| response = { | |
| 'time': total_time | |
| } | |
| return str(response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment