简体   繁体   中英

How do I execute Flask on AWS EC2 instance?

I have a Python script up and running on a AWS EC2 Ubuntu instance. I have installed Flask on the instance by following this blog .

This is my basic flask app:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
  return 'Hello from Flask!'

if __name__ == '__main__':
  app.run()

I want a method that works on AWS EC2 Ubuntu environment for the above mentioned. I am only a beginner, so I request anyone who answers to be detailed.

You can host the flask app on AWS using Elastic Beanstalk service of AWS instead of trying to make the flask app work on an EC2 instance directly by running the flask app manually. By doing it this way, your app would get hosted on a public URL so that you can access it anytime.

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