2
votes

I am trying to run my Flask Application using python 3.5 on EC2 AWS instance.
I have tried the same application on my system and it ran well using the link:

http://127.0.0.1:5000/api/v1.0/people/[email protected]

Similarly, I have launched the Flask app on AWS instance, but after hitting the url in the similar fashion, I could not see the output: http://ec2-xx-xxx-xx-xxx.compute-1.amazonaws.com:5000/api/v1.0/people/

I launched the application as:

 python3.5 FlaskRestAPI.py
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

Kindly, let me know what I need to do to see the output?

2
127.0.0.1 is the localhost interface. You'll need to bind it to an external IP, or 0.0.0.0. - Daniel Roseman
@DanielRoseman How I can do that.. please can you share with me? - Jaffer Wilson
Don't know. What does FlaskRestAPI look like? - Daniel Roseman
@DanielRoseman your idea works.. Thank you - Jaffer Wilson

2 Answers

3
votes

You'll need some sort of Webserver Gateway Interface like uWSGI or Gunicorn and most likely a web server/reverse proxy like Nginx or Apache.

Here is a nice tutorial that uses uWSGI and Nginx: http://bathompso.com/blog/Flask-AWS-Setup/

0
votes

One better way to do this would be to host your flask application on AWS using the ElasticBeanstalk service of AWS. It is a seamless process and it gets your flask application working in minutes. You also get a public URL through which you can access your flask application.

More detailed instructions available here on how to how a flask application on AWS using ElasticBeanstalk:

Hosting a flask application using ElasticBeanstalk