简体   繁体   English

将 Flask WSGI 应用程序部署到 AWS Lambda

[英]Deploy a Flask WSGI application to AWS Lambda

I want to deploy my Flask application to AWS Lambda.我想将我的 Flask 应用程序部署到 AWS Lambda。 I tried deploying it using aws-cli, but it wasn't successful.我尝试使用 aws-cli 部署它,但没有成功。 How can I deploy Flask to Lambda?如何将 Flask 部署到 Lambda?

from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/status', methods = ['GET','POST'])
def service_run():
    return "service is running"

You can deploy a Flask WSGI application to AWS Lambda using Zappa .您可以使用Zappa将 Flask WSGI 应用程序部署到 AWS Lambda。 Install zappa and configure it:安装zappa并配置它:

pip install zappa
zappa init

Then deploy it with:然后使用以下命令部署它:

zappa deploy

You can host the flask app on AWS using Elastic Beanstalk service of AWS instead of trying to use AWS Lambda.您可以使用 AWS 的 Elastic Beanstalk 服务在 AWS 上托管 Flask 应用程序,而不是尝试使用 AWS Lambda。 By doing it this way, your app would get hosted on a public URL so that you can access it anytime.通过这种方式,您的应用程序将托管在公共 URL 上,以便您可以随时访问它。 This is the quickest way to launch a flask app on AWS.这是在 AWS 上启动 Flask 应用程序的最快方式。

For more details on how to host a flask application on AWS, refer the below link:有关如何在 AWS 上托管 Flask 应用程序的更多详细信息,请参阅以下链接:

Hosting a flask app on AWS Elastic Beanstalk 在 AWS Elastic Beanstalk 上托管 Flask 应用程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM