Skip to main content

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

Project description

icon

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, 3.8, 3.9

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.5.0.tar.gz (43.1 kB view details)

Uploaded Source

Built Distribution

agraffe-0.5.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for agraffe-0.5.0.tar.gz
Algorithm Hash digest
SHA256 a31c4f7df4dc15a369eb73499030c9e30c62cda41a24483edaaf4de174375afe
MD5 a6c8d66e0b0a6925ec4d7427be34e833
BLAKE2b-256 ceaeaa3bc60dc2fb93f73aadb58dce27778da598163994dce469eda2bbf25152

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for agraffe-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d495aa1c2e58a3d916e471828efbf7247019779ea95c9bef8dfd47e5c4311219
MD5 b1d7c02b3377f055189248ced8b6ca95
BLAKE2b-256 59ad6af60fa9d3b630d8dad0b59212a91639a1dd041958199b9d98545241929d

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