Deploy a Simple API

Deploy “hello world” with a single command:

  1. Let’s take a look at the file:
dan@node1:~/deploymenow_client$ cat sample_app_hello_world.py 
import json
import random


def lambda_handler(event, context):
    choice = random.choice(["world", "you", "there"])
    return json.dumps({"statusCode": 200, "body": "Hello {}!".format(choice)})
  1. Deploy it now!
dan@node1:~/deploymenow_client$ dmn deploy sample_app_hello_world.py 
.Your application is deployed!
...Now checking if your app is ready
..Everything is ready!
{"url": "https://fun-fugu-154915548.deploymenow.com", "message": "your API is ready on our end!...but if you see a 404 in your browser, or an SSL-error, give it a few moments! Your browser may need a moment to catch up :) ..."}
  1. That was fast! …Let’s test out our new API:
dan@node1:~/deploymenow_client$ curl https://fun-fugu-154915548.deploymenow.com
{"statusCode": 200, "body": "Hello there!"}
dan@node1:~/deploymenow_client$ curl https://fun-fugu-154915548.deploymenow.com
{"statusCode": 200, "body": "Hello you!"}
dan@node1:~/deploymenow_client$ curl https://fun-fugu-154915548.deploymenow.com
{"statusCode": 200, "body": "Hello world!"}