<commit_before>import cgi
import json
import logging
import os
import traceback
import urllib
import urlparse

from constants import content_types
from pipes import Pipeline
from ranges import RangeParser
from response import MultipartContent
from utils import HTTPException

logger = logging.getLogger("wptserve")

__all__ = ["file_handler", "python_script_handler",
           "FunctionHandler", "handler", "json_handler",
           "as_is_handler", "ErrorHandler"]


def guess_content_type(path):
    ext = os.path.splitext(path)[1].lstrip(".")
    if ext in content_types:
        return content_types[ext]

    return "application/octet-stream"


class DirectoryHandler(object):
    def __call__(self, request, response):
        path = request.filesystem_path

        assert os.path.isdir(path)

        response.headers = [("Content-Type", "text/html")]
        response.content = """<!doctype html>
<meta name="viewport" content="width=device-width"></meta><commit_msg>Remove </meta>.<commit_after>import cgi
import json
import logging
import os
import traceback
import urllib
import urlparse

from constants import content_types
from pipes import Pipeline
from ranges import RangeParser
from response import MultipartContent
from utils import HTTPException

logger = logging.getLogger("wptserve")

__all__ = ["file_handler", "python_script_handler",
           "FunctionHandler", "handler", "json_handler",
           "as_is_handler", "ErrorHandler"]


def guess_content_type(path):
    ext = os.path.splitext(path)[1].lstrip(".")
    if ext in content_types:
        return content_types[ext]

    return "application/octet-stream"


class DirectoryHandler(object):
    def __call__(self, request, response):
        path = request.filesystem_path

        assert os.path.isdir(path)

        response.headers = [("Content-Type", "text/html")]
        response.content = """<!doctype html>
<meta name="viewport" content="width=device-width">
{'fraction_non_alphanumeric': 0.10599078341013825, 'fraction_numerical': 0.0010240655401945725, 'mean_word_length': 4.2668463611859835, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '313329', 'n_tokens_mistral': 565, 'n_tokens_neox': 548, 'n_words': 150}