This is a traditional Python 3 TODO app with Flask framework. This project is based on Patrick Loeber's video analysing three Python frameworks for Web apps.
This branch replaces SQLLite with MySQL DB.
If you want to understand the underlying application, please check out the main branch.
There are two main differences between this and the main branch. First, we add PyMySQL to the requirements.txt file. PyMySQL is a MySQL client for Python.
Second, we changed application.py to consider MySQL URL and retrieve necessary data from environment variables, like so:
(...)
import os
(...)
app.config['SQLALCHEMY_DATABASE_URI'] = "mysql+pymysql://{}:{}@{}/{}".format(
os.getenv("RDS_USERNAME"),
os.getenv("RDS_PASSWORD"),
os.getenv("RDS_HOSTNAME"),
os.getenv("RDS_DB_NAME"),
)
(...)
- Clone the project locally
git clone https://github.com/gabrielcostasilva/python-flask-todo.git
- In the project folder, create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate
- Install dependencies
pip install -r requiments.txt
- Create four environment variables with required data for accessing the MySQL DB as follows
export RDS_USERNAME=USERNAME-TO-ACCESS-DB
export RDS_PASSWORD=PASSWD-TO-ACCESS-DB
export RDS_HOSTNAME=LOCALHOST
export RDS_DB_NAME=DB-NAME
- Start the application
python3 application.py
- Access the app with your browser at
http://localhost:5000
First, ensure you have AWS CLI and EB CLI installed and configured.
- Clone the project locally
git clone https://github.com/gabrielcostasilva/python-flask-todo.git
- In the project folder, initilize the application
eb init \
-r us-east-1 \
-p python-3.8
- Create your Beanstalk environment
eb create -s -db.engine mysql
- When the environment is ready, access the app
eb open
- Terminate your environment
eb terminate
Note that you can use a MySQL client (e.g. Workbench) to access your database on AWS RDS using the connection URL presented on your console during the environment creation.