Get a redirect from a path or list of paths

    Arguments:

    paths -- either a single path string, or a list of paths to check

    Returns: a flask.redirect() result
771858
def get_redirect(paths):
    

    if isinstance(paths, str):
        paths = [paths]

    for path in paths:
        url, permanent = get_alias(path)
        if url:
            return redirect(url, 301 if permanent else 302)

        url, permanent = current_app.get_path_regex(path)
        if url:
            return redirect(url, 301 if permanent else 302)

    return None
522701
def catch_all(path):
    
    return (dict(error='Invalid URL: /{}'.format(path),
                 links=dict(root='{}{}'.format(request.url_root, PREFIX[1:]))),
            HTTPStatus.NOT_FOUND)
676010
def forward(self, **kwargs):
        
        # rewrite url path  
        prefix = self.url_prefix
        path= "" if request.path == "/" else request.path
        path = path[len(prefix):]
        url = '%s%s'% ( self.url_root[:-1], path )

        if request.method == 'GET':
            resp = requests.get(url, params=request.args)
            data = json.loads(resp.content)
        elif request.method == 'POST':
            if request.headers['Content-Type'].startswith('application/json'):
                # data in JSON
                resp = requests.post(url, json=request.json)
                data = request.json
            else :
                resp = requests.post(url, json=request.form)
                data = request.form
            data = json.loads(resp.content)
        else:
            # method not allowed aborting
            abort(405) # XXX

        return jsonify(data)
789204
def get_redirect_url(self, request):
        
        cp = request.GET.get('cp')
        user = request.user
        Token.objects.filter(user=user).delete()
        token = Token.objects.create(user=user)
        return '{0}?username={1}&token={2}'.format(cp, user.username, token.key)
551301
def fetch_errors_from(self, path):
        
        node = self.fetch_node_from(path)
        if node is not None:
            return node.errors
        else:
            return ErrorList()
44005
def get(self, path, params, **options):
        
        return self.request('get', path, params=params, **options)
182124
def post(self, path, query=None, data=None, redirects=True):
        
        return self.request('POST', path, query, data, redirects)
676057
def _get_redirect_url(self, request):
        
        if 'next' in request.session:
            next_url = request.session['next']
            del request.session['next']
        elif 'next' in request.GET:
            next_url = request.GET.get('next')
        elif 'next' in request.POST:
            next_url = request.POST.get('next')
        else:
            next_url = request.user.get_absolute_url()
        if not next_url:
            next_url = '/'
        return next_url
417294
def view(route: str):
    
    project = cauldron.project.get_internal_project()
    results_path = project.results_path if project else None
    if not project or not results_path:
        return '', 204

    path = os.path.join(results_path, route)
    if not os.path.exists(path):
        return '', 204

    return flask.send_file(
        path,
        mimetype=mimetypes.guess_type(path)[0],
        cache_timeout=-1
    )
4605
def get_redirect_args(self, request, callback):
        ""
        callback = force_text(request.build_absolute_uri(callback))
        raw_token = self.get_request_token(request, callback)
        token, secret = self.parse_raw_token(raw_token)
        if token is not None and secret is not None:
            request.session[self.session_key] = raw_token
        return {
            'oauth_token': token,
            'oauth_callback': callback,
        }
370418
def get_url(self, path):
        
        host = ('[' + self.host + ']' if (self.host.find(':') != -1)
                else self.host)
        base_url = self.protocol + '://' + host + ':' + str(self.port)
        return base_url + '/v3alpha/' + path.lstrip("/")
357062
def redirects(self):
        
        if self._redirects is None:
            self._redirects = list()
            self.__pull_combined_properties()
        return self._redirects
1299091
def convert_regex_to_flask_path(url_path):
    
    for token in ["$"]:
        url_path = url_path.replace(token, "")

    def caller(reg):
        match_name, match_pattern = reg.groups()
        return '<regex("{0}"):{1}>'.format(match_pattern, match_name)

    url_path = re.sub("\(\?P<(.*?)>(.*?)\)", caller, url_path)

    if url_path.endswith("/?"):
        # Flask does own handling of trailing slashes
        url_path = url_path.rstrip("/?")
    return url_path
11126
def redirect(req, _log=pymagic.get_lazy_logger("redirect")):
    
    log = req.environ.get("wsgilog.logger", _log)
    target = req.relative_url(req.urlvars.to)
    log.info("Redirecting '%s' to '%s'" % (req.url, target))
    return exc.HTTPMovedPermanently(location=target)
1188663
def get(self, path, query=None, redirects=True):
        
        return self.request('GET', path, query, None, redirects)
519189
function redirect() {
                var resultURL = urlTransform(req.url, function(parsed) {
                    parsed.pathname += '/';
                    return parsed;
                });

                res.statusCode = 301;
                res.setHeader('Location', resultURL);
                res.end('Redirecting to ' + resultURL);
            }
344841
def redirect(self, url):
        ''''''
        # TODO: Should we be overriding self.request with the new request?
        new_request = self._parse_request(url=url, handle=self.request.handle)
        log.debug('Redirecting %s to %s', self.request.path, new_request.path)
        return self._dispatch(new_request.path)