make most parts work with flask

Not yet ported is the whole session system in particular,
but maybe other stuff, too.