More doc updates, explanation of serverless. (#228)

* More doc updates, explanation of serverless.

* Moved howto directory to examples and some minor doc updates.

* Added apps and routes docs.

* Fixes for Carlos' comments.

* Added bit about importing lambda functions.
This commit is contained in:
Travis Reeder
2016-11-08 09:44:08 -08:00
committed by GitHub
parent 4717889693
commit 85e15fe48a
49 changed files with 282 additions and 99 deletions

1
examples/hello/python/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
packages/

View File

@@ -0,0 +1,6 @@
FROM iron/python:2
WORKDIR /app
ADD . /app
ENTRYPOINT ["python", "hello.py"]

View File

@@ -0,0 +1,40 @@
## 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:
```yml
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:
```sh
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.
```sh
cat hello.payload.json | fnctl run pythonapp /hello
```
Here's a curl example to show how easy it is to do in any language:
```sh
curl -H "Content-Type: application/json" -X POST -d @hello.payload.json http://localhost:8080/r/pythonapp/hello
```

View File

@@ -0,0 +1,5 @@
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

View File

@@ -0,0 +1,3 @@
{
"name": "Johnny"
}

View File

@@ -0,0 +1,12 @@
import sys
sys.path.append("packages")
import os
import json
name = "World"
if not os.isatty(sys.stdin.fileno()):
obj = json.loads(sys.stdin.read())
if obj["name"] != "":
name = obj["name"]
print "Hello", name, "!!!"

View File