<commit_before>"""
Main OWAPI App.
"""
import logging

from asphalt.core import ContainerComponent

import kyokai
from asphalt.redis.component import RedisComponent
from kyokai.asphalt import KyoukaiComponent
from kyokai.context import HTTPRequestContext

from owapi import util, routes

# Fuck your logging config.

logging.basicConfig(filename='/dev/null', level=logging.INFO)

formatter = logging.Formatter('%(asctime)s - [%(levelname)s] %(name)s -> %(message)s')
root = logging.getLogger()

consoleHandler = logging.StreamHandler()
consoleHandler.setFormatter(formatter)
root.addHandler(consoleHandler)

logger = logging.getLogger("OWAPI")


class APIComponent(ContainerComponent):
    """
    Container for other components. I think.
    """

    async def start(self, ctx):
        self.add_component('kyoukai', KyoukaiComponent, ip="127.0.0.1", port=4444,
                           app="app:app", template_renderer=None)
        self.add_component('redis', RedisComponent)
        await super().start(ctx)

        logger.info("Started OWAPI server.")


app = kyokai.Kyokai("owapi")


@app.errorhandler(404)
@util.jsonify
async def e404(ctx: HTTPRequestContext):
    return {"error": 404}, 404

app.register_blueprint(routes.bp)<commit_msg>Redirect to API docs on /<commit_after>"""
Main OWAPI App.
"""
import logging

from asphalt.core import ContainerComponent

import kyokai
from asphalt.redis.component import RedisComponent
from kyokai.asphalt import KyoukaiComponent
from kyokai.context import HTTPRequestContext
from kyokai.response import redirect

from owapi import util, routes

# Fuck your logging config.

logging.basicConfig(filename='/dev/null', level=logging.INFO)

formatter = logging.Formatter('%(asctime)s - [%(levelname)s] %(name)s -> %(message)s')
root = logging.getLogger()

consoleHandler = logging.StreamHandler()
consoleHandler.setFormatter(formatter)
root.addHandler(consoleHandler)

logger = logging.getLogger("OWAPI")


class APIComponent(ContainerComponent):
    """
    Container for other components. I think.
    """

    async def start(self, ctx):
        self.add_component('kyoukai', KyoukaiComponent, ip="127.0.0.1", port=4444,
                           app="app:app", template_renderer=None)
        self.add_component('redis', RedisComponent)
        await super().start(ctx)

        logger.info("Started OWAPI server.")


app = kyokai.Kyokai("owapi")


@app.route("/")
async def root(ctx: HTTPRequestContext):
    return redirect("https://github.com/SunDwarf/OWAPI/blob/master/api.md")


@app.errorhandler(404)
@util.jsonify
async def e404(ctx: HTTPRequestContext):
    return {"error": 404}, 404


app.register_blueprint(routes.bp)
{'fraction_non_alphanumeric': 0.12346139500186498, 'fraction_numerical': 0.01641178664677359, 'mean_word_length': 4.484662576687117, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1488327', 'n_tokens_mistral': 891, 'n_tokens_neox': 822, 'n_words': 187}