Cookiecutter-Flask (and some other stuff)

For web projects I’ve come to really appreciate projects such as cookiecutter and cookiecutter-flask, that remove a ton of boiler plate work from the beginning of development.  The parts they automate tend to be the most boring anyway.  As a Flask user, I’ve found myself using sloria’s cookiecutter pretty often, but I kept modifying the same things, so I thought it prudent to fork it and make my own changes.

A quick overview of differences between my fork and the original:

- I've restructured the python portion to have directories for models, forms, views and services, and then file for public, user, etc, rather than directory per public, user, etc. I find that separation is more logical and it's easier for my tiny brain to navigate.

- I've also begun to add in a few boiler-plate pieces of functionality that I find repetitive, but may be broader than the scope of the original template. These include things like forgotten password handling and contact forms.

So how would you use it? Pretty much the same as any other cookiecutter template.  First install cookiecutter: docs

brew install cookiecutter

Then:

cookiecutter https://github.com/wdm0006/cookiecutter-flask.git

Make the changes that you need to make (like secret key, flask-mail configs, and testing locally), then you can deploy to Heroku right away if you feel like it.  I, in fact, did feel like it, so here is a link to a real running instance of the plain vanilla template, with no modifications:

Cookiecutter-Flask Demo Site

To get your own up and running:

cd your_app git init heroku create git add -A git commit -m ‘first commit’ git push heroku master heroku run bash

python manage.py db init python manage.py db migrate python manage.py db upgrade exit heroku apps:rename yourappname heroku open

And there you go, end to end simple app in production in pretty much no time whatsoever. It’s operational now, but it is a work in progress and I’ll continue to update this blog as I get things done, so let me know if you have any suggestions.

Link to repo