<commit_before>import os
import asyncio

from mfr.core import utils as core_utils
from mfr.core.streams.base import StringStream

from mfr.server import utils
from mfr.server import settings
from mfr.server.handlers import core

from mfr.core.streams import FileStreamReader

class RenderHandler(core.BaseHandler):

    ACTION_MAP = {
        'GET': 'render',
    }

    @utils.coroutine
    def prepare(self):
        yield from super().prepare()

    @utils.coroutine
    def get(self):
        """Render a file with the extension"""
        cached_file_path = os.path.join('/tmp', 'mfr', 'files', self.unique_key)<commit_msg>Helper method for sending stream to the end users<commit_after>import os
import asyncio

from mfr.core import utils as core_utils
from mfr.core.streams.base import StringStream

from mfr.server import utils
from mfr.server import settings
from mfr.server.handlers import core

from mfr.core.streams import FileStreamReader

class RenderHandler(core.BaseHandler):

    ACTION_MAP = {
        'GET': 'render',
    }

    @utils.coroutine
    def prepare(self):
        yield from super().prepare()

    @asyncio.coroutine
    def write_stream(self, stream):
        while True:
            chunk = yield from stream.read(settings.CHUNK_SIZE)
            if not chunk:
                break
            self.write(chunk)
            yield from utils.future_wrapper(self.flush())

    @utils.coroutine
    def get(self):
        """Render a file with the extension"""
        cached_file_path = os.path.join('/tmp', 'mfr', 'files', self.unique_key)
{'fraction_non_alphanumeric': 0.09414758269720101, 'fraction_numerical': 0.0, 'mean_word_length': 3.0025445292620865, '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': '4201724', 'n_tokens_mistral': 463, 'n_tokens_neox': 466, 'n_words': 135}