Code from Miguel Grinberg's Flask tutorials