OpenWhisk | Simple HTTP Endpoint

This example demonstrates how to setup a simple HTTP GET endpoint.

Clone This Example

Step #1 - npm install serverless -g
Step #2 - serverless install -u -n  openwhisk-python-simple-http-endpoint

Serverless Boilerplate - OpenWhisk - Python

Make sure serverless is installed. See installation guide.

You will also need to set up your OpenWhisk account credentials using environment variables or a configuration file. Please see the this guide for more information.

1. Install Project Dependencies

npm install in this directory to download the modules from package.json.

2. Deploy

serverless deploy or sls deploy. sls is shorthand for the Serverless CLI command

Make a note of the API endpoint that is logged to the console during deployment.

GET --> python-service-dev-currentTime

3. Invoke deployed function

serverless invoke --function currentTime or serverless invoke -f currentTime

-f is shorthand for --function

In your terminal window you should see the response from Apache OpenWhisk

    "message": "Hello stranger, the current time is 15:59:30.983379"

4. Test HTTP endpoint

Use a HTTP client to access the endpoint for your function. The endpoint will be the API gateway root path, logged during deployment, and your configured function path.

$ http get
HTTP/1.1 200 OK
    "message": "Hello stranger, the current time is 16:00:11.837331"

$ http get
HTTP/1.1 200 OK
    "message": "Hello James, the current time is 16:00:15.749699"

For more information on the Serverless OpenWhisk plugin, please see the project repository:

view on Github

Latest commit b2f54ec on Sep 24, 2017

New to serverless?

To get started, pop open your terminal & run:

npm install serverless -g