Skip to main content

Agraffe, build API with ASGI in Serverless services (e.g AWS lambda, Google Cloud Functions and Azure Functions).

Project description

PyPI version

Agraffe, build API with ASGI in Serverless services (e.g AWS lambda, Google Cloud Functions and Azure Functions).

Support Services

  • Google Cloud Functions
  • AWS lambda (with API Gateway HTTP API and REST API)
  • Azure Functions

Requirements

Python 3.7+

Installation

$ pip install agraffe

Example

Create it

  • Create a file main.py with:
from agraffe import Agraffe, Service

from typing import Optional

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def read_root():
    return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Optional[str] = None):
    return {"item_id": item_id, "q": q}

entry_point = Agraffe.entry_point(app, Service.google_cloud_functions)
# or
from agraffe.services.google_cloud_functions import HttpCycle

def entry_point(request):
    return Agraffe(app, HttpCycle)(request=request)

Deploy it

  • Deploy the api with:
$ gcloud functions deploy {FUNCTION NAME} --entry-point entry_point --runtime python37 --trigger-http --allow-unauthenticated

License

This project is licensed under the terms of the MIT license.

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

agraffe-0.4.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

agraffe-0.4.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file agraffe-0.4.0.tar.gz.

File metadata

  • Download URL: agraffe-0.4.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.0

File hashes

Hashes for agraffe-0.4.0.tar.gz
Algorithm Hash digest
SHA256 ced6cb4e60998acd60ba17600aa86fec72387c9a42b9921de53ed0e8ad49bfcf
MD5 c34d6b4489e3a703996d206feb7e32f8
BLAKE2b-256 b6c4901d740098596a4e2e5a46502c1355144e95a91978e32bda113e3a6713de

See more details on using hashes here.

File details

Details for the file agraffe-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: agraffe-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.0

File hashes

Hashes for agraffe-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0033a19fb5dad0878698fd1f038bd48f07a40b2c5373bc59a5e81b3abc2420a2
MD5 183738304b3b08aacf34c17cafa94aa7
BLAKE2b-256 d21fe8e8e9572937f0c84630f1452f088bcd169850ea91607a230a39f6745112

See more details on using hashes here.

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