<commit_before>import os
import sys
import logging
import uuid

from flask import Flask, render_template, jsonify, request
from pymongo import MongoClient
from smartconfigparser import Config

from bus import Bus
from repository import MongoRepository
from handlers import CreateRangeVoteHandler
from commands import CreateRangeVoteCommand, CreateRangeVoteCommandValidator


logger = logging.getLogger(__name__)


def configure_logging():
    root = logging.getLogger()
    root.setLevel(logging.DEBUG)
    handler = logging.StreamHandler(sys.stdout)
    handler.setLevel(logging.DEBUG)
    formatter = logging.Formatter('%(asctime)s  %(name)12s %(levelname)7s - %(message)s')
    handler.setFormatter(formatter)
    root.addHandler(handler)


class Server():
    def __init__(self, repository):
        root_dir = os.path.dirname(__file__)
        self.app = Flask(__name__,
                         static_folder=os.path.join(root_dir, 'client', 'static'),
                         template_folder=os.path.join(root_dir, 'client'))
        self.app.add_url_rule('/', view_func=self.index)
        self.app.add_url_rule('/rangevotes/', view_func=self.handle_rangevotes, methods=['POST'])
        configure_logging()

        self.bus = Bus()
        self.bus.register(CreateRangeVoteCommand, CreateRangeVoteHandler(repository))

    @staticmethod
    def index():
        return render_template('index.html')

    def handle_rangevotes(self):
        if CreateRangeVoteCommandValidator(request.json).is_valid():
            command = CreateRangeVoteCommand(uuid.uuid4(), request.json['question'], request.json['choices'])
            result = self.bus.send(command)

            if result.ok:<commit_msg>rename handle_rangevotes function<commit_after>import os
import sys
import logging
import uuid

from flask import Flask, render_template, jsonify, request
from pymongo import MongoClient
from smartconfigparser import Config

from bus import Bus
from repository import MongoRepository
from handlers import CreateRangeVoteHandler
from commands import CreateRangeVoteCommand, CreateRangeVoteCommandValidator


logger = logging.getLogger(__name__)


def configure_logging():
    root = logging.getLogger()
    root.setLevel(logging.DEBUG)
    handler = logging.StreamHandler(sys.stdout)
    handler.setLevel(logging.DEBUG)
    formatter = logging.Formatter('%(asctime)s  %(name)12s %(levelname)7s - %(message)s')
    handler.setFormatter(formatter)
    root.addHandler(handler)


class Server():
    def __init__(self, repository):
        root_dir = os.path.dirname(__file__)
        self.app = Flask(__name__,
                         static_folder=os.path.join(root_dir, 'client', 'static'),
                         template_folder=os.path.join(root_dir, 'client'))
        self.app.add_url_rule('/', view_func=self.index)
        self.app.add_url_rule('/rangevotes/', view_func=self.create_rangevotes, methods=['POST'])
        configure_logging()

        self.bus = Bus()
        self.bus.register(CreateRangeVoteCommand, CreateRangeVoteHandler(repository))

    @staticmethod
    def index():
        return render_template('index.html')

    def create_rangevotes(self):
        if CreateRangeVoteCommandValidator(request.json).is_valid():
            command = CreateRangeVoteCommand(uuid.uuid4(), request.json['question'], request.json['choices'])
            result = self.bus.send(command)

            if result.ok:
{'fraction_non_alphanumeric': 0.1032069970845481, 'fraction_numerical': 0.0023323615160349854, 'mean_word_length': 3.7193947730398897, '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': '4243272', 'n_tokens_mistral': 983, 'n_tokens_neox': 949, 'n_words': 197}