Skip to main content

Framework to develop multi cloud APIs.

Project description

About

This package provides a framework to develop portable APIs. Supported platforms: Azure Functions, AWS Lambda, GPC, Flask.

Install

pip install chestnut

How to use

Write functions to handle your API operation using the package chestnut.http request/response classes. Then, depending on the platform you want to deploy to, add a conversion layer.

Develop your API

from chestnut.http import Request, Response


def handler(req: Request) -> Response:
	message = "Hello {} !".format(
		req.query_params.get("name", "anonymous")
	)
	return Response(status=200, body=message)

Deploy on Azure

import azure.functions as func
from chestnut.layers.azure import azure_layer
from <package.module> import handler


def main(req: func.HttpRequest) -> func.HttpResponse:
	return azure_layer(handler, req)

Deploy on AWS

from chestnut.layers.aws import aws_layer
from <package.module> import handler


def handler(event: dict, context: dict) -> dict:
	return aws_layer(handler, event)

Deploy on Google Cloud

import flask
from chestnut.layers.aws import gcp_layer
from <package.module> import handler


def hello_http(request: flask.Request) -> flask.Response:
	return gcp_layer(handler, request)

Unit test

pip install -r requirements.txt -r test-requirements.txt
python -m pytest tests/ --cov=chestnut

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

chestnut-0.0.1.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

chestnut-0.0.1-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page