Files
fn-serverless/docs/howto/python
C Cirello 5b3971060b Per language HOWTO's on writing functions (#208)
* fnctl: improve UX for howto's

* doc: go function howto

* fnctl: show the progress of build calls

* doc: php function howto

* doc: fix Go HOWTO

* doc: Node Functions HOWTO

* doc: Python Functions HOWTO

* doc: improve README files

* doc: ccirello -> USERNAME

* docs: fix Python example

Used an idiomatic method (isatty) to decide whether stdin must
be read or not.

* doc: fix go example

* fnctl: fix docker push output
2016-11-02 00:19:16 +01:00
..

Quick Example for a Python Function (4 minutes)

This example will show you how to test and deploy Go (Golang) code to IronFunctions.

1. Prepare the functions.yaml file:

At functions.yaml you will find:

app: pythonapp
route: /hello
image: USERNAME/hello:0.0.1
build:
- docker run --rm -v "$PWD":/worker -w /worker iron/python:2-dev pip install -t packages -r requirements.txt

The important step here is to ensure you replace USERNAME with your Docker Hub account name. Some points of note: the application name is pythonapp and the route for incoming requests is /hello. These informations are relevant for the moment you try to test this function.

2. Build:

fnctl publish

-v is optional, but it allows you to see how this function is being built.

3. Queue jobs for your function

Now you can start jobs on your function. Let's quickly queue up a job to try it out.

cat hello.payload.json | fnctl run pythonapp /hello

Here's a curl example to show how easy it is to do in any language:

curl -H "Content-Type: application/json" -X POST -d @hello.payload.json http://localhost:8080/r/pythonapp/hello