Best Flask open-source libraries and packages

Updated 2 years ago

forthebadge made-with-python

Requirements Status Travis example workflow Coverage Docker

Pallets

Example app for demonstrating continuos integration/continuos deployment (CI/CD) workflows -- inspired by dockercloud-quickstart-python.

The example flask app connects to a redis instance and displays a simple visit counter and the hostname of the docker container serving the app.

Technical Stack

Flask HTML5 CSS3

Postgres Redis Nginx

CI - CD

TravisCI GitHub Actions

Getting started

Install docker and run:

docker-compose up
# docker-compose stop

Otherwise, for the standalone web service:

pip install -r requirements.txt
python app.py

Visit http://localhost:5000

Development

Create a new branch off the develop branch for features or fixes.

After making changes rebuild images and run the app:

docker-compose build
docker-compose run -p 5000:5000 web python app.py
# docker stop flaskapp_redis_1

Tests

Standalone unit tests run with:

pip install pytest pytest-cov pytest-flask
pytest --cov=web/ --ignore=tests/integration tests

Integration and unit tests run with:

docker-compose -f test.yml -p ci build
docker-compose -f test.yml -p ci run test python -m pytest --cov=web/ tests
# docker stop ci_redis_1 ci_web_1

Commits tested via travis-ci.org. Test coverage reported to codecov.io. Code quality reported via codeclimate.com. Requirements inspected with requires.io.

After testing, submit a pull request to merge changes with develop.

Automated builds and redeploys

Docker images are automatically built from changes to repo branches and tags via docker hub autobuilds.

Using a cluster provisioned on docker cloud, services are created as stacks from stack/ to nodes tagged infra or compute. Setting stack option autoredeploy: true continuously redeploys new images built from recent commits.

Image tagging and deployment scheme:

Note: To create sites at subdomains using virtual hosts as shown in stack/, assumes domain records have been configured with:

  • CNAME record * to example.com.
  • A record @ to the (floating) IP of the haproxy load balancer

Monitoring, log aggregation and scaling

Agent containers by sematext deployed to each node. Alert thresholds trigger web hooks to scale services under load.

Notifications

Updates and alerts pushed via Slack:

  • github
  • travis-ci
  • docker
  • sematext
Tags pallets