An example of reading data

The code for our new function is still quite simple:

import jsondef handler(context):    print context.json    return context.json

All this code does is take the JSON we post and display it back to us. Place it in a file called hello-name.py or use the one in the Chapter04/hello-world/ folder in the GitHub repository. Once you have the file you can create the function by running:

$ kubeless function deploy hello-name \   --from-file hello-name.py \   --handler hello-name.handler \   --runtime python2.7 \   --trigger-http

Once you have deployed the function, you check it has been created by running:

$ kubeless function ls

You should see two functions listed, hello and hello-name. Now that we have created our new function you can ...

Get Kubernetes for Serverless Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.