Code from Flask tutorial.