Module | Package | Description |
---|---|---|
Database | Flask-SQLAlchemy | |
Database migration | Flask-Migrate | |
Authentication | Flask-Login | |
Flask WTFForm | https://flask-wtf.readthedocs.io/en/stable/ | |
Flask-Mail | ||
Restful API | Flask-Restful | |
Flask Caching | Flask-caching | |
JWT Authentication | Flask-JWT-Entended | |
Hash Password | Flask-Bcrypt | |
Redis | Flask-redis | |
Celery | http://flask.pocoo.org/docs/1.0/patterns/celery/ | |
AMQP | Pika | Working with RabbitMQ |
Testing | Pytest | |
Apply Middleware | ||
uwsgi | ||
Traefik | ||
HTTPS/SSL | Let's Encrypt | |
Kubernetes | ||
Sentry | https://sentry.io/for/flask/ | |
Docker | ||
docker-compose | ||
SMTP Mail Server | mailcatcher | Fake smtp email server for testing email |
- Celery was used for sending email in async fashion
- Clone source code
git clone https://github.com/phsontung/flask-skeleton
- Build flaskapp
docker-compose build flaskapp
- Run flask application
docker-compose up
- Install pipenv for working with Pipfile and virtualenv
pip install pipenv
- Change directory to flask-skeleton and install dependencies
pipenv install --dev
- Create
.env
file (flask environment variables)
# Flask built-in environment variables
# Flask built-in environment variables
FLASK_ENV=development
SERVER_NAME=0.0.0.0
FLASK_APP=run.py
FLASK_DEBUG=1
# User define environmnet variables
FLASK_APP_ENV=dev
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_USERNAME=test
DATABASE_PASSWORD=test
DATABASE_NAME=test
# Sentry DSN (should not set in local development)
SENTRY_DSN=https://f8066db528df41cd92170dc04fcb1f55@sentry.io/1488966
- Activate virtualenv
pipenv shell
- Run flask application
# flash run
* Serving Flask app "app.py" (lazy loading)
* Environment: development
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 206-413-235
- Note: In case you run with postgresql, you can use docker-compose to run postgresql only (+ mailcatcher if need)
docker-compose up postgres mailcatcher
- Structure of Flask application
- Authentication and Authorization with Flask-Login
- Cookiecutter-flask
- Token based authentication with flask
- Docker container for flask micro service
- Swagger UI
- Create pull requests if you can bring something cool (constructive)
- Create issues if you feel something wrong
- Add Travis CI: https://travis-ci.org
- Add code coverage: https://codecov.io
- Add code climate: https://codeclimate.com
- Pyup.io: https://pyup.io/
- Reload flask app and install pip packages when running with docker-compose