Steps 1-7 from http://flask.pocoo.org/docs/tutorial.