Sample code from my "Introduction to Flask" presentation. The slides for this presentation are available at https://speakerdeck.com/miguelgrinberg/introduction-to-flask.
- Migrate
- flask-api: show how to build an api
- flask-blueprint: this how to separete endpoits using blueprints
- flask-cache: this app show how to use the default config for redis
- flask-celery: app with defined tasks to add paralelization with celery library
- flask-feedback-app: general feedback app example
- flask-jwt: app to perfom authentitacion using jwt
- flask-k8s: app with the basic k8s implementation
- flask-logging: using logging library to add and get logs
- flask-login-decorator: app axample to demostrate how to use decorator for login
- flask-migrate: app example to demonstrate the migrations steps using alembic
- flask-postgree: app exaple using postgree database
- flask-probes: app to simulatef probes endpoints
- flask-pymongo: app exmple to demostrate how to connectioon in mongo db using flask
- flask-rabbitmq: connect to rabbitmq message queue mechanism
- flask-redis: app that show the use of redis in a simple way
- flask-rest-sqlite: a simple rest app builded using sqlite
- flask-sendmail: example of sendmail app
- flask-session: controling sessions
- flask-sqlite: database for sqlite
- flask-test: test example using unitiitest and pytest
All those applications should be dockerized and in some case use docker compose to compose the needed dependencies
You can create a virtual environment and install the required packages with the following commands:
$ virtualenv venv
$ . venv/bin/activate
(venv) $ pip install -r requirements.txt
Since we have enabled each project folder with Docker, we cab up some of those services using docker composer.
Running all registered:
$ docker-composer up
Running a specific:
$ cd flask-api
$ docker-composer up flask-api
With the virtual environment activated you can cd
into any of the examples and run the main script.
For examples 1-6:
$ pipenv shell
(venv) $ pipenv install
(venv) $ python app.py
For example 7:
(venv) $ python manage.py