Skip to main content

serverless your django/flask apps

Project description

Serverless + Python

简介

serverlessplus 是一个简单易用的工具,它可以帮助你将现有的 django / flask 等框架构建的应用借助 API 网关 迁移到 腾讯云无服务云函数(Tencent Cloud Serverless Cloud Function)上。

开始使用

$ python3 -m pip install serverlessplus

假设有如下 flask 应用:

# app.py
from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
    return 'hello world'

添加 index.py 作为服务的入口文件, 内容如下:

# encoding: utf8
from serverlessplus import create_environ, create_app, get_response, wrap_response

# specify entrypoint, `${file_name}:${callable_object}`
APP = 'app:app'
app = create_app(APP)

def main_handler(event, context):
    environ = create_environ(event, context)
    response = get_response(app, environ)
    return wrap_response(response, {'binary_mime_types': ['image/png']})

示例

支持的框架

serverlessplus 被设计为通过 WSGI 与框架进行交互. 理论上, 只要框架支持 WSGI, 就可以使用 serverlessplus

路线图

  • 更多 Web 框架的支持与测试

serverlessplus 处于活跃开发中,API 可能在未来的版本中发生变更,我们十分欢迎来自社区的贡献,你可以通过 pull request 或者 issue 来参与。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for serverlessplus, version 0.0.8
Filename, size File type Python version Upload date Hashes
Filename, size serverlessplus-0.0.8-py3-none-any.whl (7.9 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size serverlessplus-0.0.8.tar.gz (7.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page