示例#1
0
    def redir_host(self, host=None, path=None, status=None):
        if not host:
            host = self.app_host

        if not host or request.environ.get('HTTP_HOST') == host:
            return

        url = request.environ['wsgi.url_scheme'] + '://' + host
        if not path:
            path = request.environ.get('SCRIPT_NAME', '') + request.environ['PATH_INFO']
            if request.query_string:
                path += '?' + request.query_string

        url += path
        return bottle_redirect(url, code=status)
示例#2
0
def redirect(url):
    if url.startswith('/'):
        url = get_host() + url

    return bottle_redirect(url)
示例#3
0
def redirect(url):
    if url.startswith('/'):
        url = get_host() + url

    return bottle_redirect(url)
示例#4
0
    def redirect(self, url):
        if url.startswith('/'):
            url = self.get_host() + quote(url, safe='+ /!:%?$=&#')

        return bottle_redirect(url)