为阿里无服务函数提供API网关的协议解析
Project description
aligi
Aliyun Gateway Interface
为无服务函数计算作为阿里云 API 后端运行提供转析,并且允许同一个无服务函数既支持 HTTP 触发器,也支持作为 API 网关的后端服务。
为什么会有这个库?
使用 Flask,Django 等支持标准 WSGI 协议的 Web 框架创建无服务函数时,使用HTTP触发器才能让它们正常运行。
但如果想使用无服务函数作为阿里云 API 网关的后端时,则无法直接使用这些函数,只能通过网络调用,这显然是不够高效、并且费钱的。
如何安装
在项目根目录下执行
pip install -t . aligi
如何使用
以下为一个最小的 Flask 样例
from flask import Flask
from aligi import WSGI
app = Flask(__name__)
@app.route("/")
def hello_world():
return "Hello, World!"
# 阿里云无服务函数的入口
handler = WSGI(app)
其中app
可以是任意一个标准 WSGI Application。
在 Django 项目中,它一般在项目的wsgi.py
里。
参考文档
阿里云文档:
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
aligi-0.1.2.tar.gz
(5.3 kB
view hashes)
Built Distribution
Close
Hashes for aligi-0.1.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e229dd8debb4ddc8c2e62cd452058bc4dddcc9c22b70b4b17a1b56d9e680a1b |
|
MD5 | 7ebec48467c948571830542b8ca83c49 |
|
BLAKE2b-256 | e5bbcb56ff2c882c233a087fff2960019bad2756c9cff3313453a808f29050f6 |