<commit_before>"""
API endpoints for lolbot.
If you're looking for the cog that powers the API,
you are in the wrong place. You are looking for
api_launcher.py.
"""
from quart import Quart, jsonify

app = Quart(__name__)
app.bot = None


# Basic shit
@app.route("/")
async def no():
    return jsonify({'no': 'go away'})


@app.route("/api/ping")
async def wsping():
    return jsonify({'ws': round(app.bot.latency, 3)})


# Stats endpoints
@app.route("/api/stats/<whatever>")
async def stats(whatever):
    if whatever is 'guilds':
        return jsonify({'guilds': len(app.bot.guilds)})
    elif whatever is 'shards':
        return jsonify({'shards': len(app.bot.shards)})
    elif whatever is 'ready':
        return jsonify({'ready': app.bot.is_ready()})
    elif whatever is 'all':
        return jsonify({
            'ready': app.bot.is_ready(),
            'guilds': len(app.bot.guilds),
            'shards': len(app.bot.shards)
        })
    else:
        print(f'got: {whatever}')
        return jsonify({'error': 404})
<commit_msg>cogs[api]: fix for stats 404<commit_after>"""
API endpoints for lolbot.
If you're looking for the cog that powers the API,
you are in the wrong place. You are looking for
api_launcher.py.
"""
from quart import Quart, jsonify

app = Quart(__name__)
app.bot = None


# Basic shit
@app.route("/")
async def no():
    return jsonify({'no': 'go away'})


@app.route("/api/ping")
async def wsping():
    return jsonify({'ws': round(app.bot.latency, 3)})


# Stats endpoints
@app.route("/api/stats/<whatever>")
async def stats(whatever):
    if whatever == 'guilds':
        return jsonify({'guilds': len(app.bot.guilds)})
    elif whatever == 'shards':
        return jsonify({'shards': len(app.bot.shards)})
    elif whatever == 'ready':
        return jsonify({'ready': app.bot.is_ready()})
    elif whatever == 'all':
        return jsonify({
            'ready': app.bot.is_ready(),
            'guilds': len(app.bot.guilds),
            'shards': len(app.bot.shards)
        })
    else:
        print(f'got: {whatever}, type: {type(whatever)}')
        return jsonify({'error': 404})

{'fraction_non_alphanumeric': 0.1639267261625176, 'fraction_numerical': 0.005166744950681071, 'mean_word_length': 3.057142857142857, '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': '4570183', 'n_tokens_mistral': 744, 'n_tokens_neox': 701, 'n_words': 198}