A Python Boilerplate Project for flask, mongoengine, flask_mongoengine, flask-restful, tornado and Flask-Script
To get you started you can simply clone the Boilerplate-FlaskRestMongoTornado repository and install the dependencies:
git clone https://github.com/zerodine/Boilerplate-FlaskRestMongoTornado.git
cd Boilerplate-FlaskRestMongoTornado
We have some dependencies in this project. Just use pip:
pip install flask
pip install mongoengine
pip install flask_mongoengine
pip install flask-restful
pip install tornado
pip install Flask-Script
#pip install flask-debugtoolbar #optional
flaskboilerplate/ --> demo project, just rename or copy it
apps/ --> all the apps go in here
core/ --> demo app called core
commands/ --> cli commands (flask-script)
demo.py --> just a demo command
config/ --> config files for app
config.py --> general config for the app (environment does not matter here)
config_dev.py --> config for dev environment
config_test.py --> config for test environment
config_prod.py --> config for test environment
documents/ --> all your odm Documents
demo.py --> an example Document
resources/ --> app resources
demo.py --> a demo resource with a simply get method
views/ --> app views
demo.py --> a demo which returns a simple string
config/ --> config files for project
config.py --> general config for the project (environment does not matter here)
config_dev.py --> config for dev environment
config_test.py --> config for test environment
config_prod.py --> config for test environment
manage.py --> manage (e.g. import commands)
runserver.py --> run script
To create a new command simply make a file in project/apps/app-name/commands with the command in it. Here is a example:
from flask.ext.script import Command
class Demo(Command):
"""
prints hello world
"""
def run(self):
print "hello world"
To add the command to the project, add following line to manage.py
from flaskdemo.apps.core.commands import sub_manager as core_sub_manager
manager.add_command("core", core_sub_manager)
To create a full features package run the following command which creates dist/*.tar.gz
python setup.py sdist
For more information about this project, checkout: