<commit_before>'''
'''

from paste.cascade import Cascade
from paste.errordocument import make_errordocument
from paste.recursive import RecursiveMiddleware
from paste.translogger import TransLogger
from paste.urlparser import StaticURLParser
from weberror.errormiddleware import ErrorMiddleware
from weberror.evalexception import EvalException

from core import abort, error_for, override_template, Pecan, redirect, render, request, response, ValidationException
from decorators import expose
from templating import error_formatters

from configuration import set_config
from configuration import _runtime_conf as conf

__all__ = [
    'make_app', 'Pecan', 'request', 'response', 'override_template', 'expose', 'conf', 'set_config' 
]

def make_app(root, static_root=None, debug=False, errorcfg={}, wrap_app=None, logging=False, **kw):
    '''
    
    '''

    app = Pecan(root, **kw)
    if wrap_app:
        app = wrap_app(app)
    app = RecursiveMiddleware(app)
    if debug:
        app = EvalException(app, templating_formatters=error_formatters, **errorcfg)
    else:
        app = ErrorMiddleware(app, **errorcfg)
    app = make_errordocument(app, conf, **conf.app.errors)
    if static_root:
        app = Cascade([StaticURLParser(static_root), app])
    if isinstance(logging, dict) or logging == True:
        app = TransLogger(app, **(isinstance(logging, dict) and logging or {}))
    return app<commit_msg>Adds the RequestViewerHook to the app automagically<commit_after>'''
'''

from paste.cascade import Cascade
from paste.errordocument import make_errordocument
from paste.recursive import RecursiveMiddleware
from paste.translogger import TransLogger
from paste.urlparser import StaticURLParser
from weberror.errormiddleware import ErrorMiddleware
from weberror.evalexception import EvalException

from core import abort, error_for, override_template, Pecan, redirect, render, request, response, ValidationException
from decorators import expose
from hooks import RequestViewerHook
from templating import error_formatters

from configuration import set_config
from configuration import _runtime_conf as conf

__all__ = [
    'make_app', 'Pecan', 'request', 'response', 'override_template', 'expose', 'conf', 'set_config' 
]

def make_app(root, static_root=None, debug=False, errorcfg={}, wrap_app=None, logging=False, **kw):
    '''
    
    '''

    app = Pecan(root, **kw)
    if wrap_app:
        app = wrap_app(app)
    app = RecursiveMiddleware(app)
    if debug:
        app = EvalException(app, templating_formatters=error_formatters, **errorcfg)
    else:
        app = ErrorMiddleware(app, **errorcfg)
    app = make_errordocument(app, conf, **conf.app.errors)
    if static_root:
        app = Cascade([StaticURLParser(static_root), app])
    if isinstance(logging, dict) or logging == True:
        app = TransLogger(app, **(isinstance(logging, dict) and logging or {}))
    if conf.requestviewer:
        existing_hooks = kw.get('hooks', [])
        if RequestViewerHook not in existing_hooks:
            existing_hooks.append(RequestViewerHook(conf.requestviewer.as_dict()))
            kw['hooks'] = existing_hooks
    return app
{'fraction_non_alphanumeric': 0.0967741935483871, 'fraction_numerical': 0.0, 'mean_word_length': 4.638146167557932, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5271852', 'n_tokens_mistral': 918, 'n_tokens_neox': 929, 'n_words': 259}