Last active
March 3, 2019 22:58
-
-
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"
This file contains 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 | |
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