Don't use cgi and cgitb

They're never needed when using flask... That was the 90's way of doing
web
Set up logging first

Logging setup should almost always be the first thing to set up, after
importing stuff and specifying a couple of constants