Flask application which is:
- a simple API with restricted access to premium users only
- JWT authentication
- a Swagger documentation
- a user web interface for registration with email activation, lost password recovery, and token retrieval
Development is done by launching Flask local web server: FLASK_APP=flaskapp.py flask run
The application is deployed with Docker. The front web server is Nginx. The connector between Flask and Nginx is uwsgi.
Here is the command in order to create and launch a Docker container in production.
docker run \
--publish 80:80 \
--volume /var/log/flaskapp:var/log/flaskapp \
--volume /home/user_files/flaskapp:/home/user_files/flaskapp \
--env "USER_FOLDERS_PATH=/home/user_files/flaskapp" \
--env "LOG_FILE_PATH=/var/log/flaskapp" \
--detach \
--name my_container \
my_account/my_repo:my_tag
Run local migrations during dev:
FLASK_APP=flaskapp.py flask db init (first time only)
FLASK_APP=flaskapp.py flask db migrate
FLASK_APP=flaskapp.py flask db upgrade
Once the app is ready to go to production, change database credentials in order to connect to production database and create tables structure:
FLASK_APP=flaskapp.py flask upgrade