All Projects → cburmeister → Flask Bones

cburmeister / Flask Bones

Licence: mit
An example of a large scale Flask application using blueprints and extensions.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Flask Bones

Node Developer Boilerplate
🍭 Boilerplate for ES6+ Node.js and npm Developer
Stars: ✭ 82 (-90.34%)
Mutual labels:  babel, yarn, travis-ci
Enferno
A Python framework based on Flask microframework, with batteries included, and best practices in mind.
Stars: ✭ 385 (-54.65%)
Mutual labels:  sqlalchemy, flask
Wordpress Starter
📦 A starter template for WordPress websites
Stars: ✭ 26 (-96.94%)
Mutual labels:  babel, yarn
Full Stack
Full stack, modern web application generator. Using Flask, PostgreSQL DB, Docker, Swagger, automatic HTTPS and more.
Stars: ✭ 451 (-46.88%)
Mutual labels:  sqlalchemy, flask
Databook
A facebook for data
Stars: ✭ 26 (-96.94%)
Mutual labels:  sqlalchemy, flask
Flask Sqlalchemy
Adds SQLAlchemy support to Flask
Stars: ✭ 3,658 (+330.86%)
Mutual labels:  sqlalchemy, flask
Mini Shop Server
基于 Flask 框架开发的微信小程序后端项目,用于构建小程序商城后台 (电商相关;rbac权限管理;附带自动生成Swagger 风格的API 文档;可作「Python 项目毕设」;慕课网系列)---- 相关博客链接:🌟
Stars: ✭ 446 (-47.47%)
Mutual labels:  sqlalchemy, flask
Hare
🐇 Application boilerplate based on Vue.js 2.x, Koa 2.x, Element-UI and Nuxt.js
Stars: ✭ 258 (-69.61%)
Mutual labels:  babel, yarn
Potion
Flask-Potion is a RESTful API framework for Flask and SQLAlchemy, Peewee or MongoEngine
Stars: ✭ 484 (-42.99%)
Mutual labels:  sqlalchemy, flask
Flask Rest Jsonapi
Flask extension to build REST APIs around JSONAPI 1.0 specification.
Stars: ✭ 566 (-33.33%)
Mutual labels:  sqlalchemy, flask
Slinky
A light-weight, responsive, mobile-like navigation menu plugin
Stars: ✭ 649 (-23.56%)
Mutual labels:  babel, yarn
Graphql Starter
💥 Monorepo template (seed project) pre-configured with GraphQL API, PostgreSQL, React, Relay, and Material UI.
Stars: ✭ 3,377 (+297.76%)
Mutual labels:  babel, yarn
Flask Sqlacodegen
🍶 Automatic model code generator for SQLAlchemy with Flask support
Stars: ✭ 283 (-66.67%)
Mutual labels:  sqlalchemy, flask
Gulp Scss Starter
Frontend development with pleasure. SCSS version
Stars: ✭ 339 (-60.07%)
Mutual labels:  babel, yarn
Vue.js Starter Template
A starter template for Vue.js projects
Stars: ✭ 267 (-68.55%)
Mutual labels:  babel, yarn
Data Driven Web Apps With Flask
Course demo code and other hand-out materials for our data-driven web apps in Flask course
Stars: ✭ 388 (-54.3%)
Mutual labels:  sqlalchemy, flask
Mixer
Mixer -- Is a fixtures replacement. Supported Django, Flask, SqlAlchemy and custom python objects.
Stars: ✭ 743 (-12.49%)
Mutual labels:  sqlalchemy, flask
react-enterprise-starter-kit
Highly Scalable Awesome React Starter Kit for an enterprise application with a very easy maintainable codebase. 🔥
Stars: ✭ 55 (-93.52%)
Mutual labels:  babel, travis-ci
Safrs
SqlAlchemy Flask-Restful Swagger Json:API OpenAPI
Stars: ✭ 255 (-69.96%)
Mutual labels:  sqlalchemy, flask
Flask Restplus Boilerplate
A boilerplate for flask restful web service
Stars: ✭ 466 (-45.11%)
Mutual labels:  sqlalchemy, flask

flasks

flask-bones

An example of a large scale Flask application using blueprints and extensions.

Build Status

Setup

Quickly run the project using docker and docker-compose:

docker-compose up -d

Create the database and seed it with some data:

docker-compose run --rm app flask create-db
docker-compose run --rm app flask populate-db --num_users 5

Download front-end dependencies with yarn:

yarn install --modules-folder ./app/static/node_modules

Configuration

The following environment variables are optional:

Name Purpose
APP_NAME The name of the application. i.e Flask Bones
MAIL_PORT The port number of an SMTP server.
MAIL_SERVER The hostname of an SMTP server.
MEMCACHED_HOST The hostname of a memcached server.
MEMCACHED_PORT The port number of a memcached server.
POSTGRES_HOST The hostname of a postgres database server.
POSTGRES_PASS The password of a postgres database user.
POSTGRES_PORT The port number of a postgres database server.
POSTGRES_USER The name of a postgres database user.
REDIS_HOST The hostname of a redis database server.
REDIS_PORT The port number of a redis database server.
SECRET_KEY A secret key required to provide authentication.
SERVER_NAME The hostname and port number of the server.

Features

Caching with Memcached

from app.extensions import cache

# Cache something
cache.set('some_key', 'some_value')

# Fetch it later
cache.get('some_key')

Email delivery

from app.extensions import mail
from flask_mail import Message

# Build an email
msg = Message('User Registration', sender='[email protected]', recipients=[user.email])
msg.body = render_template('mail/registration.mail', user=user, token=token)

# Send
mail.send(msg)

Asynchronous job scheduling with RQ

RQ is a simple job queue for python backed by redis.

Define a job:

@rq.job
def send_email(msg):
    mail.send(msg)

Start a worker:

flask rq worker

Queue the job for processing:

send_email.queue(msg)

Monitor the status of the queue:

flask rq info --interval 3

For help on all available commands:

flask rq --help

Stupid simple user management

from app.extensions import login_user, logout_user, login_required

# Login user
login_user(user)

# You now have a global proxy for the user
current_user.is_authenticated

# Secure endpoints with a decorator
@login_required

# Log out user
logout_user()

Password security that can keep up with Moores Law

from app.extensions import bcrypt

# Hash password
pw_hash = bcrypt.generate_password_hash('password')

# Validate password
bcrypt.check_password_hash(pw_hash, 'password')

Easily swap between multiple application configurations

from app.config import dev_config, test_config

app = Flask(__name__)

class dev_config():
    DEBUG = True

class test_config():
    TESTING = True

# Configure for testing
app.config.from_object(test_config)

# Configure for development
app.config.from_object(dev_config)

Form validation & CSRF protection with WTForms

Place a csrf token on a form:

{{ form.csrf_token }}

Validate it:

form.validate_on_submit()

Rate-limit routes

from app.extensions import limiter

@limiter.limit("5 per minute")
@auth.route('/login', methods=['GET', 'POST'])
def login():
    # ...
    return 'your_login_page_contents'

Automated tests

Run the test suite:

pytest

Use any relational database using the SQLAlchemy ORM

from app.user.models import User

# Fetch user by id
user = User.get_by_id(id)

# Save current state of user
user.update()

# Fetch a paginated set of users
users = User.query.paginate(page, 50)

Front-end asset management

Download front-end dependencies with yarn:

yarn install --modules-folder ./app/static/node_modules

Merge and compress them together with Flask-Assets:

flask assets build

Version your database schema

Display the current revision:

flask db current

Create a new migration:

flask db revision

Upgrade the database to a later version:

flask db upgrade

Internationalize the application for other languages (i18n)

Extract strings from source and compile a catalog (.pot):

pybabel extract -F babel.cfg -o i18n/messages.pot .

Create a new resource (.po) for German translators:

pybabel init -i i18n/messages.pot -d i18n -l de

Compile translations (.mo):

pybabel compile -d i18n

Merge changes into resource files:

pybabel update -i i18n/messages.pot -d i18n
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].