Set up middleware dispatcher if app root is set

`DispatcherMiddleware` is the magic that makes `url_for` prepend a root
path, but it’s not quite compatible with the `Flask` object, so have to
tweak a few minor related things