This guide outlines the steps to deploy a Flask web application with a MongoDB backend on AWS Elastic Beanstalk.
-
AWS Account:
- Ensure you have an AWS account. If not, sign up for an account at AWS.
-
AWS CLI and Elastic Beanstalk CLI:
- Install the AWS CLI by following the instructions here.
- Install the Elastic Beanstalk CLI by running
pip install awsebcli
.
-
MongoDB:
- Set up a MongoDB database and obtain the MongoDB URI.
-
Git:
- Install Git from https://git-scm.com/.
-
Python and Pip:
- Ensure you have Python and Pip installed on your machine.
- source venv/bin/activate
- pip install -r requirements.txt
- flask run
- Open localhost:5000
- source venv/bin/activate
- pip freeze | xargs pip uninstall -y
- deactivate
In the case of all dependencies are correctly installed but the app gets ModuleNotFoundError
, do the following:
- Close all IDE and terminal
- Open IDE and terminal again
- Install the most recent stable python version https://www.python.org/downloads/windows/
- python -m pip install --upgrade pip
- virtualenv venv
- set-executionpolicy remotesigned
- .\venv\Scripts\activate
- pip install -r requirements.txt
py -3.12 -m pip uninstall awsebcli