/flask-skeleton

Flask boilerplate / skeleton for develop a cool website or backend API

Primary LanguageHTMLMIT LicenseMIT

WIP: flask-skeleton

What's included?

Module Package Description
Database Flask-SQLAlchemy
Database migration Flask-Migrate
Authentication Flask-Login
Flask WTFForm https://flask-wtf.readthedocs.io/en/stable/
Email 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

How it works?

  • Celery was used for sending email in async fashion

Let's get start

  • Clone source code
git clone https://github.com/phsontung/flask-skeleton

Work with docker-compose

  • Build flaskapp
docker-compose build flaskapp
  • Run flask application
docker-compose up

Run flaskapp in local virtual environment

  • 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

References

Wanna help?

  • Create pull requests if you can bring something cool (constructive)
  • Create issues if you feel something wrong

TODO