<commit_before># Standard lib imports
import json
import re
from urllib.parse import unquote_plus
from http.cookies import SimpleCookie
from datetime import datetime, timedelta
from traceback import format_exc

# Own imports
from framework.status_codes import status_codes
from framework.database import make_db_connection, close_db_connection
from framework.routes import find_path, abort
import framework.database
import framework.mail
from modules.util import json_serial


config = {
    'debug': False,
}


def update_config(conf_):
    """
    Updates configs for various modules.
    """

    config.update(conf_)
    framework.database.config.update(conf_)
    framework.mail.config.update(conf_)


def serve(environ, start_response):
    """
    Handle a WSGI request and response.
    """

    db_conn = make_db_connection()
    request = construct_request(db_conn, environ)
    code, data = call_handler(request)
    close_db_connection(db_conn)
    response_headers = [('Content-Type', 'application/json; charset=utf-8')]
    if isinstance(data, dict):
        response_headers += set_cookie_headers(data.pop('cookies', {}))
    status = str(code) + ' ' + status_codes.get(code, 'Unknown')
    start_response(status, response_headers)
    if isinstance(data, str):
        body = data.encode()
    elif isinstance(data, dict):
        body = json.dumps(data, default=json_serial, ensure_ascii=False)
        body = body.encode()
    return [body]


def construct_request(db_conn, environ):
    """
    Produce a request `object`
    given a body (get), query string (put, post), and cookies.
    """

    request = {}<commit_msg>text/plain for sitemap<commit_after># Standard lib imports
import json
import re
from urllib.parse import unquote_plus
from http.cookies import SimpleCookie
from datetime import datetime, timedelta
from traceback import format_exc

# Own imports
from framework.status_codes import status_codes
from framework.database import make_db_connection, close_db_connection
from framework.routes import find_path, abort
import framework.database
import framework.mail
from modules.util import json_serial


config = {
    'debug': False,
}


def update_config(conf_):
    """
    Updates configs for various modules.
    """

    config.update(conf_)
    framework.database.config.update(conf_)
    framework.mail.config.update(conf_)


def serve(environ, start_response):
    """
    Handle a WSGI request and response.
    """

    db_conn = make_db_connection()
    request = construct_request(db_conn, environ)
    code, data = call_handler(request)
    close_db_connection(db_conn)
    response_headers = []
    if isinstance(data, dict):
        response_headers += [
            ('Content-Type', 'application/json; charset=utf-8')
        ]
        response_headers += set_cookie_headers(data.pop('cookies', {}))
    else:
        response_headers += [('Content-Type', 'text/plain; charset=utf-8')]
    status = str(code) + ' ' + status_codes.get(code, 'Unknown')
    start_response(status, response_headers)
    if isinstance(data, dict):
        data = json.dumps(data, default=json_serial, ensure_ascii=False)
    return [data.encode()]


def construct_request(db_conn, environ):
    """
    Produce a request `object`
    given a body (get), query string (put, post), and cookies.
    """

    request = {}
{'fraction_non_alphanumeric': 0.10301582561958794, 'fraction_numerical': 0.0008957897879964168, 'mean_word_length': 3.8976608187134505, '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': '3918125', 'n_tokens_mistral': 986, 'n_tokens_neox': 975, 'n_words': 259}