from miguelgrinberg's mega flask tutorial