Flaskr tutorial from http://flask.pocoo.org/docs/tutorial/