Agraffe, build API with ASGI in Serverless services (e.g AWS lambda, Google Cloud Functions and Azure Functions).
Support Services
- Google Cloud Functions
- Python 3.7, 3.8, 3.9, 3.10, 3.11(preview)
- AWS lambda (with API Gateway HTTP API or REST API, or with Function URL)
- Python 3.7, 3.8, 3.9
- Azure Functions
- Python 3.7, 3.8, 3.9, 3.10(preview)
Requirements
Python 3.7+
Installation
$ pip install agraffe
Example
Create it
- Create a file
main.pywith:
import contextlib
from agraffe import Agraffe
from fastapi import FastAPI, Request
@contextlib.asynccontextmanager
async def lifespan(app):
yield {'message': 'hello'}
app = FastAPI(lifespan=lifespan)
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: str | None = None):
return {"item_id": item_id, "q": q}
@app.get("/lifespan")
def lifespan_(request: Request):
return {"count": request.state.message}
entry_point = Agraffe.entry_point(app)
# or, for on GCP
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 python310 --trigger-http --allow-unauthenticated
See /example for other services.
License
This project is licensed under the terms of the MIT license.
Metadata
Release files for agraffe 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agraffe-0.7.0.tar.gz | 52.3 kB | Without provenance | Details for agraffe-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agraffe-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for agraffe-0.7.0-py3-none-any.whl |
Total release size: 61.2 kB
Release files / agraffe-0.7.0.tar.gz
| Download URL | agraffe-0.7.0.tar.gz |
|---|---|
| Size | 52.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fc1cb578bb9bc8290cb9f7317babe61d20fb794a73b49f7087743fe26d5ac13a
|
|
BLAKE2b-256 checksum How to use checksums |
31fd78580ea1c8aee2e8a4eac948014bd5fe439a40bfee4f89ebd3603bd670f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.28.2
|
Release files / agraffe-0.7.0-py3-none-any.whl
| Download URL | agraffe-0.7.0-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2bc70168854801fa3d8c5cefc9f17515d17a6b938c61894667e98714d804e3cc
|
|
BLAKE2b-256 checksum How to use checksums |
2e07f1d20063815b7cbf7a9cd85c946c7f8d2328e353b219ca20ff67e5b9c2af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.28.2
|
Security for agraffe 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.