No project description provided
Project description
Function framework for Python
This framework provides a mechanism to write Function-as-a-Service style code in Python for handling HTTP events, including CloudEvents delivered via HTTP.
This framework is primarily intended to work with Knative, but also works to provide a generic server for handling CloudEvents over HTTP (e.g. from Kubernetes or on a local machine).
The framework uses reflection to find a suitable function to wrap; it should not be necessary to import any of the following modules in your own code unless you want (e.g. for type definitions):
frameork
(this module; on PyPi ashttp-containerize
)flask
cloudevents
Instead, simply ensure that you have a single non-_
prefixed function which
uses some combination of the following:
- HTTP request arguments (named
req
,request
,body
,headers
or of theflask.Request
type) - CloudEvent arguments (named
event
,payload
,data
,attributes
or of thecloudevents.sdk.event.v1.Event
type)
Usage:
import logging
from typing import Any
counter = 0
def DoEvent(data: Any, attributes: dict, req: Any):
logging.info(f"Got data: {data}")
counter = counter + 1
logging.info(f"From {req.origin}, my {counter}th request!")
attributes["type"] = "com.example.reply"
attributes["datacontenttype"] = "text/plain"
return attributes, "It's a dema"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for http_containerize-0.3.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50819414c0afcf5f4058779deec42dd681ee8f07c612147e70b37649b9e76578 |
|
MD5 | 185b2c58b5acd5684dee2e160e875b46 |
|
BLAKE2b-256 | 7bca6d75532b879ee411ef80573826143388fbdd0325a1c3e27eb314112ba9e4 |