<commit_before># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from __future__ import absolute_import

import flask
import requests
import structlog

log = structlog.get_logger()
bp = flask.Blueprint('treestatus', __name__)


API_URL = "https://treestatus.mozilla-releng.net/"
URL = "https://mozilla-releng.net/treestatus"


@bp.route('/')
def home():
    log.info('Redirecting treestatus frontend')
    return flask.redirect(URL)


@bp.route('/<path:path>')
def proxy_api(path):
    log.info('Proxying treestatus path: ' + path)

    # fetch the url, and stream it back
    response = requests.get(
        API_URL + path,
        stream=True,
        params=flask.request.args,
    )

    # reply with reponse from requests library
    log.info('Received treestatus response with status code %s' % (response.status_code))  # no-qa
    return flask.Response(
        response=flask.stream_with_context(response.iter_content()),<commit_msg>treestatus: adding redirect for details page<commit_after># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from __future__ import absolute_import

import flask
import requests
import structlog

log = structlog.get_logger()
bp = flask.Blueprint('treestatus', __name__)


API_URL = "https://treestatus.mozilla-releng.net/"
URL = "https://mozilla-releng.net/treestatus"


@bp.route('/')
def home():
    log.info('Redirecting to treestatus.')
    return flask.redirect(URL)


@bp.route('/details/<path:tree>')
def tree_details(tree):
    log.info('Redirecting to tree: %s.' % tree)
    return flask.redirect('%s/show/%s' % (URL, tree))


@bp.route('/<path:path>')
def proxy_api(path):
    log.info('Proxying treestatus path: ' + path)

    # fetch the url, and stream it back
    response = requests.get(
        API_URL + path,
        stream=True,
        params=flask.request.args,
    )

    # reply with reponse from requests library
    log.info('Received treestatus response with status code %s' % (response.status_code))  # no-qa
    return flask.Response(
        response=flask.stream_with_context(response.iter_content()),
{'fraction_non_alphanumeric': 0.12141652613827993, 'fraction_numerical': 0.003372681281618887, 'mean_word_length': 3.6804733727810652, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5272978', 'n_tokens_mistral': 773, 'n_tokens_neox': 740, 'n_words': 216}