A simple flask app to manage users along with mysql service now with docker support.
Youtube Tutorial Walkthrough: https://www.youtube.com/watch?v=As90fkeMkyA
To run the app flawlessly, satisfy the requirements
pip install -r requirements.txt
Replace .env.example
with .env
file and update the environment vaiables.
FLASK_APP=app.py
FLASK_ENV=development
FLASK_DEBUG=True
# DB info
MYSQL_HOST=localhost
MYSQL_USER=root
MYSQL_PASSWORD=
MYSQL_DB=lms
Note: If you update the MYSQL_DB
variable, remember to also update the corresponding value in the docker-compose.yaml file to ensure consistency when using Docker. There's an exceptioin for MYSQL_HOST
which should set set within docker-compose.yaml file explicitly.
To setup a mail server you can set the below variable in .env
file.
# SMTP credentials
MAIL_SERVER=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_USE_TLS=True
MAIL_USE_SSL=
MAIL_DEBUG=1
MAIL_DEFAULT_SENDER=sender@domain.com
I'm using Flask-Mail for managing emails. For more information, visit https://flask-mail.readthedocs.io/en/latest/
Export lms.sql
database from within db directory using Phpmyadmin or terminal:
mysql -u <username> -p <password> lms < lms.sql
flask run
Or run this command
python -m flask run
Start flask with auto reload on code change
flask run --reload
With this update, you can now easily get an out-of-the-box support for a Docker environment. There's no need to set up a mysql service, import databases, or run multiple commands.
Create an .env
file as described in the Set Environment Variables section, then execute the docker-compose
command. This will automate the entire setup process for you.
Build & start the app:
docker-compose up --build
OR
Start app (without building):
docker-compose up