Asgi-aws

Latest version: v2.0.0

Safety actively analyzes 623343 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

2.0.0

What's Changed
* Support Python 3.11 & Use Hatch as Project management by yezz123 in https://github.com/yezz123/asgi-aws/pull/7
* Bump pypa/gh-action-pypi-publish from 1.8.1 to 1.8.3 by dependabot in https://github.com/yezz123/asgi-aws/pull/8

New Contributors
* dependabot made their first contribution in https://github.com/yezz123/asgi-aws/pull/8

**Full Changelog**: https://github.com/yezz123/asgi-aws/compare/1.0.0...2.0.0

1.0.0

asgi-aws

Build API with ASGI in AWS Lambda with API Gateway HTTP API or REST API, or with
Function URL ✨

Installation

sh
pip install asgi_aws


Example

- Create a file `main.py` with:

python
from asgi_aws import Asgi, AsgiService
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 = Asgi.entry_point(app, AsgiService.aws)


Deploy it

- Let's create for example a YAML file with the following content:

yaml
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31

Resources:
ExFunctionUrlAPI:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.9
CodeUri: src/
Handler: main.entry_point
MemorySize: 256
Timeout: 30
FunctionUrlConfig:
AuthType: NONE
Environment:
Variables:
AsgiService: AWS Lambda


- Now, we can deploy the function with the following command:

sh
deploy HTTP API
sam build -t api.yaml --use-container
sam run deploy


**Note:** You can also deploy the function under Deployment for Rest API or with
a Function URL.

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.