<commit_before>from werkzeug.wrappers import Request, Response
from werkzeug.wsgi import ClosingIterator
from werkzeug.exceptions import HTTPException
from werkzeug.routing import Map, Rule
from werkzeug.serving import run_simple

class App(object):
    def __init__(self):
        self.url_map = Map()
        self.Request = Request
        self.Response = Response

    def expose(self, rule, **kwargs):
        def decorator(func):
            kwargs['endpoint'] = func
            self.url_map.add(Rule(rule, **kwargs))
            return func

        return decorator

    def __call__(self, environ, start_response):
        request = self.Request(environ)
        adapter = self.url_map.bind_to_environ(environ)
        try:
            endpoint, values = adapter.match()
            response = endpoint(request, **values)
            if isinstance(response, basestring):
                response = self.Response(response)
        except HTTPException, e:
            response = e
        return ClosingIterator(response(environ, start_response), [])

    def run(self, host='localhost', port=8000, use_reloader=True, **kwargs):
        run_simple(host, port, self, use_reloader=use_reloader, **kwargs)<commit_msg>werkzeug -> webob<commit_after>from routes.mapper import Mapper
from webob import Request, Response
from webob.exc import HTTPException, HTTPNotFound
from wsgiref.simple_server import make_server

class App(object):
    def __init__(self):
        self.url_map = Mapper()
        self.Request = Request
        self.Response = Response

    def expose(self, rule, **kwargs):
        def decorator(func):
            kwargs['endpoint'] = func
            self.url_map.connect(None, rule, **kwargs)
            return func

        return decorator

    def __call__(self, environ, start_response):
        request = self.Request(environ)
        try:
            result = self.url_map.match(None, environ)
            if not result:
                raise HTTPNotFound()

            endpoint = result.pop('endpoint')
            response = endpoint(request, **result)
            if isinstance(response, basestring):
                response = self.Response(response)
        except HTTPException, e:
            response = e

        return response(environ, start_response)

    def run(self, host='localhost', port=8000):
        httpd = make_server(host, port, self)
        httpd.serve_forever()
{'fraction_non_alphanumeric': 0.09293680297397769, 'fraction_numerical': 0.003304419661296985, 'mean_word_length': 2.5461200585651538, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '3040914', 'n_tokens_mistral': 657, 'n_tokens_neox': 652, 'n_words': 170}