I'm a beginner using AWS Beanstalk and now trying to test deploying a simple Flask app using the EB CLI. I have installed EB CLI on Amazon Linux, create new directory for flask and setup new virtual environment in that directory (called virt)
I have generated two files i.e. application.py as well as requirements.txt
from flask import Flask
application = Flask(__name__)
@application.route('/')
def hello_world():
return 'Hello, AWS Elastic Beanstalk!'
if __name__ == '__main__':
# Use port 8080 (or any port >= 1024) instead of 80 for local development
application.run(host='0.0.0.0')
The requirements.txt:
- blinker==1.7.0
- click==8.1.7
- Flask==3.0.0
- importlib-metadata==7.0.1
- itsdangerous==2.1.2
- Jinja2==3.1.3
- MarkupSafe==2.1.3
- Werkzeug==3.0.1
- zipp==3.17.0
When I test it with python3 application.py, I receive this with error message: dklf4jistiwtg.cloudfront.net refused to connect.
> (virt) ec2-user:~/environment/eb-flask $ python3 application.py *
> Serving Flask app 'application' * Debug mode: off WARNING: This is a
> development server. Do not use it in a production deployment. Use a
> production WSGI server instead. * Running on all addresses (0.0.0.0)
> * Running on http://127.0.0.1:5000 * Running on http://172.31.28.1:5000
What I've tried:
- Changing the port to 8080 in the code. Doesn't work as well
Please advise, appreciate it! I know we need to create .ebextensions file if we were to upload the zip from local, not sure if this is related.