Exemple #1
0
    def test_redir(match_host, request_uri, referrer, script_name = ''):
        env = {'REL_REQUEST_URI': request_uri, 'HTTP_REFERER': referrer, 'SCRIPT_NAME': script_name}

        redir = ReferRedirect(match_host)
        req = WbRequest.from_uri(request_uri, env)
        rep = redir(req)
        if not rep:
            return False

        return rep.status_headers.get_header('Location')
Exemple #2
0
    def __call__(self, env):
        for route in self.routes:
            result = route(env, self.abs_path)
            if result:
                return result

        # Home Page
        if env['REL_REQUEST_URI'] in ['/', '/index.html', '/index.htm']:
            return self.render_home_page()

        if not self.fallback:
            return None

        return self.fallback(WbRequest.from_uri(None, env))