def get_view_function(app, url, method):
<EOL>adapter = app.create_url_adapter(request)<EOL>try:<EOL><INDENT>match = adapter.match(url, method=method)<EOL><DEDENT>except RequestRedirect as ex:<EOL><INDENT>return get_view_function(app, ex.new_url, method)<EOL><DEDENT>except (MethodNotAllowed, NotFound):<EOL><INDENT>return None<EOL><DEDENT>try:<EOL><INDENT>return app.view_functions[match[<NUM_LIT:0>]]<EOL><DEDENT>except KeyError:<EOL><INDENT>return None<EOL><DEDENT>
Match a url and return the view and arguments
    it will be called with, or None if there is no view.
    Creds: http://stackoverflow.com/a/38488506