anslapi-1.0.1
توضیحات
Module for creating a simple API with AWS Lambda and API Gateway
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | anslapi-1.0.1 |
| نام | anslapi |
| نسخه کتابخانه | 1.0.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | anttin |
| ایمیل نویسنده | muut.py@antion.fi |
| آدرس صفحه اصلی | https://github.com/anttin/anslapi |
| آدرس اینترنتی | https://pypi.org/project/anslapi/ |
| مجوز | - |
# anslapi
A python3 module for creating a simple API with AWS Lambda and API Gateway.
## Install
```shell
python3 -m pip install anslapi
```
## Configuration
Create an api gateway with the methods that are needed, and set up authentication, schemas, etc. as wished. Create a Lambda function and configure our function as the target for each method. Use Lambda proxy mode.
## Usage example
```python
from anslapi import APIHandler
def get_user(userid):
return "user.name@example.com"
def add(event):
import json
result = {
"status": "FAIL"
}
j = json.loads(event["body"])
if "userid" in j:
result["response"] = cls.get_user(j["userid"])
result["status"] = "SUCCESS"
return (200, result)
else:
result["reason"] = "Invalid request"
return (400, result)
def lambda_handler(event, context):
ah = APIHandler()
ah.add_handler('/add', 'POST', Actions.add)
response = ah.handle(event)
return response
```
نحوه نصب
نصب پکیج whl anslapi-1.0.1:
pip install anslapi-1.0.1.whl
نصب پکیج tar.gz anslapi-1.0.1:
pip install anslapi-1.0.1.tar.gz