Skip to content

Instantly share code, notes, and snippets.

@Vadorequest
Last active March 3, 2019 22:58
Show Gist options
  • Save Vadorequest/aff8e9ce2dcc4c67637a34f567190825 to your computer and use it in GitHub Desktop.
Save Vadorequest/aff8e9ce2dcc4c67637a34f567190825 to your computer and use it in GitHub Desktop.
Example how to ping another website from AWS Lambda with Zappa, file path is "scripts/management/commands/ping.py"
import urllib.request
from django.core.management.base import BaseCommand
class Command(BaseCommand):
"""
Example:
zappa manage staging ping
zappa manage staging "ping --address https://google.com"
"""
help = "Ping given url"
def add_arguments(self, parser):
parser.add_argument(
'--address',
dest='address',
help='Address, either IP address or host address (127.0.0.1, google.com, etc.',
default='https://api.jetadmin.io'
)
def handle(self, *args, **options):
address = options.get('address')
print(urllib.request.urlopen(address).read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment