def METHOD_NAME() -> Response:
    repo = flask.request.args.get('repo')
    name_type = flask.request.args.get('name_type')
    name = flask.request.args.get('name')
    noautoresolve = bool(flask.request.args.get('noautoresolve'))
    target_page = None
    for allowed_target_page in _ALLOWED_TARGET_PAGES:
        if allowed_target_page.endpoint == flask.request.args.get('target_page'):
            target_page = allowed_target_page
            break
    template_url = None
    if repo and name_type and target_page:
        if repo not in repometadata.active_names():
            return (flask.render_template('tools/project-by/failed.html', reason='no_repo'), 404)
        elif name:
            targets = []
            for project in get_db().get_projects_by_name(repo=repo, name_type=name_type, name=name):
                possible_args = {'name': project, 'repo': repo}
                real_args = {k: possible_args[k] for k in target_page.args}
                targets.append((project, flask.url_for(target_page.endpoint, **real_args)))
            if not targets:
                return (flask.render_template('tools/project-by/failed.html', reason='no_package'), 404)
            elif noautoresolve and len(targets) > 1:
                if target_page.type_ == EndpointType.JSON:
                    return (
                        json.dumps(
                            {
                                '_comment': 'Ambiguous redirect, multiple target projects are possible',
                                'targets': {
                                    project: url for project, url in targets
                                }
                            }
                        ),
                        300,
                        {'Content-type': 'application/json'},
                    )
                else:
                    return (
                        flask.render_template(
                            'tools/project-by/ambiguity.html',
                            targets=targets,
                        ),
                        300
                    )
            else:
                return flask.redirect(targets[0][1], 302)
        else:
            args = {k: v for k, v in flask.request.args.items() if k in _EXTRA_ALLOWED_ARGS | {'repo', 'name_type', 'noautoresolve', 'target_page'}}
            template_url = url_for_self(**args)
    return flask.render_template(
        'tools/project-by.html',
        allowed_target_pages=_ALLOWED_TARGET_PAGES,
        template_url=template_url,
    )