No project description provided
Project description
pyfun
Knative function framework for Python
This framework attempts to provide
Usage:
import logging
from pyfun_events import Handle,Get
counter = 0
# @Handle assumes json body. For string or other body conversion, try:
# @Handle(str)
@Handle
def DoEvent(data: str, context: dict):
logging.info(data)
counter = counter + 1
@Handle(path="/secret")
def DoOther(data: str, context: dict):
if data.get("handshake") == "backwards":
counter = 0
return "It's gone, man"
@Get
def Info():
return "Got {0}".format(counter)
@Get("/dance"):
def Party():
return "<BLINK>Like it's 1999</BLINK>"
Running manually
Copy packaging/config.py
and packaging/requirements.txt
into your
application directory alongside your other code. You can then start the Flaskk webserver running your function with:
FLASK_APP=config
flask run
Running on Knative
There is a supplied build template in packaging/build-template.yaml
, which you can apply to your cluster with:
kubectl apply -f packaging/build-template.yaml
or
kubectl apply -f https://github.com/evankanderson/pyfun/tree/master/packaging/build-template.yaml
Then update your Knative Service like so:
apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
name: message-dumper
spec:
runLatest:
configuration:
+ build:
+ source:
+ git:
+ url: YOUR_REPO_URL
+ revision: HEAD
+ template:
+ name: pyfn
+ arguments:
+ - name: IMAGE
+ value: YOUR_DOCKER_IMAGE
+ serviceAccountName: builder
revisionTemplate:
spec:
container:
image: YOUR_DOCKER_IMAGE
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyfun_events-0.2.0.tar.gz
(3.1 kB
view hashes)
Built Distribution
Close
Hashes for pyfun_events-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b48e159059b7f88946e33a338106ea93ba514882c0813721ac60c734e666f8f7 |
|
MD5 | 669964ed09a11d6159e7502746e96100 |
|
BLAKE2b-256 | 1b5e8b402b016cc8eebb8409620a0a29723379e81d9adb086d7951d5b6d53027 |