<commit_before>import json

from flask import Blueprint, abort, current_app, jsonify
import requests

environments = Blueprint('environments', __name__, template_folder="templates")


@environments.route('/<environment>')
def environ(environment='dev'):
    try:
        url = current_app.config['ENVIRONMENTS'][environment]
        response = requests.get(url)
        if response.status_code is not 200:
            abort(424)
        return jsonify({environment: json.loads(response.text)})
    except KeyError:
        abort(404)


@environments.route('/')
def environs():
    return jsonify(current_app.config['ENVIRONMENTS'])
<commit_msg>improved environments response<commit_after>import json

from flask import Blueprint, abort, current_app, jsonify
import requests

environments = Blueprint('environments', __name__, template_folder="templates")


@environments.route('/<environment>')
def environ(environment='dev'):
    try:
        url = current_app.config['ENVIRONMENTS'][environment]
        response = requests.get(url)
        if response.status_code is not 200:
            abort(424)
        return jsonify({environment: json.loads(response.text)})
    except KeyError:
        abort(404)


@environments.route('/')
def environs():
    envs = {}
    for env in current_app.config['ENVIRONMENTS'].keys():
        envs.update(json.loads(environ(env).response[0]))
    return jsonify(envs)

{'fraction_non_alphanumeric': 0.12241992882562278, 'fraction_numerical': 0.013523131672597865, 'mean_word_length': 4.075812274368231, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '238219', 'n_tokens_mistral': 424, 'n_tokens_neox': 408, 'n_words': 88}