Skip to content

Instantly share code, notes, and snippets.

@viveksyngh
Last active July 15, 2019 19:48
Show Gist options
  • Save viveksyngh/ed67f26d3454b0403f333fbf3552a208 to your computer and use it in GitHub Desktop.
Save viveksyngh/ed67f26d3454b0403f333fbf3552a208 to your computer and use it in GitHub Desktop.
Astronaut Counter Handler
import requests
import random
import logging
import time
logging.basicConfig(level=logging.DEBUG)
def handle(req):
logging.debug("Making request to open notify API")
start = time.time()
r = requests.get("http://api.open-notify.org/astros.json")
logging.debug(
"Request completed. Total time taken %s", time.time() - start
)
result = r.json()
return result["number"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment