<commit_before>import tornado.ioloop
import tornado.web
from tornado import gen
import motor
import random
from tornado import escape
import tornado.options
from tornado.options import options


tornado.options.define('port', default=8888, type=int, help=(
    "Server port"))


db = motor.MotorClient("127.0.0.1").open_sync().hello_world

class JsonSerializeTestHandler(tornado.web.RequestHandler):
    @tornado.web.asynchronous
    @gen.coroutine
    def get(self):
        obj = dict(message="Hello, World!")
        self.write(obj)

class QueryTestHandler(tornado.web.RequestHandler):
    @tornado.web.asynchronous
    @gen.coroutine
    def get(self):
        queries = int(self.get_argument("queries", 0))

        if queries == 0:
            random_id = random.randint(1, 10000)
            world = yield gen.Task(db.world.find_one,{"randomNumber": random_id}, fields={"_id": 0, "id": 1, "randomNumber": 1})
            # Get first postion on arguments, and so first postion in mongo return
            world = world[0][0]
        else:
            worlds = []
            for i in xrange(int(queries)):
                random_id = random.randint(1, 10000)
                world = yield gen.Task(db.world.find_one,{"randomNumber": random_id}, fields={"_id": 0, "id": 1, "randomNumber": 1})
                # Get first postion on arguments, and so first postion in mongo return
                worlds.append(world[0][0])

            worlds = escape.json_encode(worlds)
            self.set_header("Content-Type", "application/json; charset=UTF-8")

        self.write(worlds if queries > 0 else world)

application = tornado.web.Application([
    (r"/json", JsonSerializeTestHandler),
    (r"/db", QueryTestHandler),
])

if __name__ == "__main__":
    tornado.options.parse_command_line()
    application.listen(options.port)
    tornado.ioloop.IOLoop.instance().start()
<commit_msg>corrected query<commit_after>import tornado.ioloop
import tornado.web
from tornado import gen
import motor
import random
from tornado import escape
import tornado.options
from tornado.options import options


tornado.options.define('port', default=8888, type=int, help=(
    "Server port"))


db = motor.MotorClient("127.0.0.1").open_sync().hello_world

class JsonSerializeTestHandler(tornado.web.RequestHandler):
    @tornado.web.asynchronous
    @gen.coroutine
    def get(self):
        obj = dict(message="Hello, World!")
        self.write(obj)

class QueryTestHandler(tornado.web.RequestHandler):
    @tornado.web.asynchronous
    @gen.coroutine
    def get(self):
        queries = int(self.get_argument("queries", 0))

        if queries == 0:
            random_id = random.randint(1, 10000)
            world = yield gen.Task(db.world.find_one,{"id": random_id}, fields={"_id": 0, "id": 1, "randomNumber": 1})
            # Get first postion on arguments, and so first postion in mongo return
            world = world[0][0]
        else:
            worlds = []
            for i in xrange(int(queries)):
                random_id = random.randint(1, 10000)
                world = yield gen.Task(db.world.find_one,{"id": random_id}, fields={"_id": 0, "id": 1, "randomNumber": 1})
                # Get first postion on arguments, and so first postion in mongo return
                worlds.append(world[0][0])

            worlds = escape.json_encode(worlds)
            self.set_header("Content-Type", "application/json; charset=UTF-8")

        self.write(worlds if queries > 0 else world)

application = tornado.web.Application([
    (r"/json", JsonSerializeTestHandler),
    (r"/db", QueryTestHandler),
])

if __name__ == "__main__":
    tornado.options.parse_command_line()
    application.listen(options.port)
    tornado.ioloop.IOLoop.instance().start()

{'fraction_non_alphanumeric': 0.1259298618490967, 'fraction_numerical': 0.019128586609989374, 'mean_word_length': 2.9968152866242037, 'pattern_counts': {'":': 18, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7345997', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1155, 'n_words': 269}