0

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"
0

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

14 Comments

thanks for the answer, it will generate only one url right ?
It's all about the route. Yes it will give you one url generally like domain name and then you can access the flask route /whatever. i.e) zappa give your url like this https://something.aws.lambda.com/api then you can access info using https://something.aws.lambda.com/api/info
hi @Raja, I tried zappa it was working fine for simple hello world program
but for my flask function im getting An uncaught exception happened while servicing this request. You can investigate this with the zappa tail` command` pls help
hi zappa tail is not working (.env) C:\Users\ELCOT\.aws\flask-app>zappa tail usage: zappa [-h] [-v] [--color {auto,never,always}] {certify,deploy,init,package,template,invoke,manage,rollback,schedule,status,tail,undeploy,unschedule,update,shell} ... zappa: error: Please supply a stage to interact with.
|
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.