This is a basic and containerized Flask application to help start coding using Flask in the backend.
Required:
docker
anddocker-compose
must be installed in your machine.
- Docker e Docker compose
- Python + Flask + Flask-SQLAlchemy (ORM)
- Postgresql
web
: backend module running the flask application.db
: database containers running the postgresql dbadminer
: database admin similiar to phpMyAdmin
Run the following commands in the root directory. Commands:
- Create .env file base on
.env.dist
:cp .env.dist .env
- Start containers:
docker-compose up
(use-d
aferter up to start the container in the background) - Stop containers:
docker-compose down
Migrations
- Run the following lines when needs to manage migrations:
- Usage:
flask db [OPTIONS] COMMAND [ARGS]...
flask db init
: to create a folder with set to migration.flask db migrate -m "Initial migration."
: to generate a migration.flask db [upgrade|downgrade]
: to up/down changes based on migration files.flask db --help
: Show database help message.
Tips
__init__.py
files means that the directory is a package- In
.env
:SECRET_KEY
: This is a secret key to secure your session data and cookies of your applicationFLASK_DEBUG
: It must beFalse
when you deploy your application toProduction
- Flask App: http://localhost:8000/
- Adminer: http://localhost:8080/