コード例 #1
0
    def redirect(self, location, code=302, empty=False):
        """Returns a response object with headers set for redirection to the
        given URI. This won't stop code execution, so you must return when
        calling this method::

            return self.redirect('/some-path')

        :param location:
            A relative or absolute URI (e.g., '../contacts'). If relative, it
            will be joined to the current request URL.
        :param code:
            The HTTP status code for the redirect.
        :param empty:
            If True, returns a response without body. By default Werkzeug sets
            a standard message in the body.
        :returns:
            A :class:`Response` object with headers set for redirection.
        """
        if not location.startswith('http'):
            # Make it absolute.
            location = urlparse.urljoin(self.request.url, location)

        response = base_redirect(location, code)

        if empty:
            response.data = ''

        return response
コード例 #2
0
ファイル: app.py プロジェクト: peper/tipfy
    def redirect(self, location, code=302):
        """Returns a response object with headers set for redirection to the
        given URI. This won't stop code execution, so you must return when
        calling this method::

            return self.redirect('/some-path')

        :param location:
            A relative or absolute URI (e.g., '../contacts'). If relative, it
            will be joined to the current request URL.
        :param code:
            The HTTP status code for the redirect.
        :returns:
            A :class:`Response` object with headers set for redirection.
        """
        if not location.startswith("http"):
            # Make it absolute.
            location = urlparse.urljoin(self.request.url, location)

        return base_redirect(location, code)