简体   繁体   中英

Deploy a Flask WSGI application to AWS Lambda

I want to deploy my Flask application to AWS Lambda. I tried deploying it using aws-cli, but it wasn't successful. How can I deploy Flask to 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 . Install zappa and configure it:

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. By doing it this way, your app would get hosted on a public URL so that you can access it anytime. This is the quickest way to launch a flask app on AWS.

For more details on how to host a flask application on AWS, refer the below link:

Hosting a flask app on AWS Elastic Beanstalk

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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