<commit_before>import os
import zmq
import atexit
from multiprocessing import cpu_count
from flask import Flask, send_from_directory, request
from werkzeug.utils import secure_filename

from cc_server.commons.gunicorn_integration import WebApp
from cc_server.commons.configuration import Config


app = Flask('cc-server-files')

config = Config()
INPUT_FILES_DIR = os.path.expanduser(config.server_files['input_files_dir'])
RESULT_FILES_DIR = os.path.expanduser(config.server_files['result_files_dir'])


def at_exit(sockets):
    for s in sockets:
        s.close()

context = zmq.Context()
logger_socket = context.socket(zmq.PUSH)
logger_socket.connect(config.server_log['external_url'])
tee = logger_socket.send_string

atexit.register(at_exit, [logger_socket])


@app.route('/<file_name>', methods=['GET'])
def get_file(file_name):
    file_name = secure_filename(file_name)
    tee('Sending file: {}').format(file_name)
    return send_from_directory(INPUT_FILES_DIR, file_name, as_attachment=True)


@app.route('/<file_name>', methods=['POST'])
def post_file(file_name):
    file_name = secure_filename(file_name)
    file_path = os.path.join(RESULT_FILES_DIR, file_name)
    with open(file_path, 'wb') as f:
        f.write(request.data)
    tee('Receiving file: {}').format(file_name)
    return ''


def main():
    options = {
        'bind': '{}:{}'.format(
            config.server_files['bind_host'],
            config.server_files['bind_port']
        ),
        'workers': config.server_files.get('num_workers', cpu_count()),
        'worker_class': 'gevent'
    }

    tee('Started cc-server-files with pid {}'.format(os.getpid()))

    WebApp(app_module='cc_server.services.files.wsgi', options=options).run()

if __name__ == '__main__':
    main()<commit_msg>bug fix in files<commit_after>import os
import zmq
import atexit
from multiprocessing import cpu_count
from flask import Flask, send_from_directory, request
from werkzeug.utils import secure_filename

from cc_server.commons.gunicorn_integration import WebApp
from cc_server.commons.configuration import Config


app = Flask('cc-server-files')

config = Config()
INPUT_FILES_DIR = os.path.expanduser(config.server_files['input_files_dir'])
RESULT_FILES_DIR = os.path.expanduser(config.server_files['result_files_dir'])


def at_exit(sockets):
    for s in sockets:
        s.close()

context = zmq.Context()
logger_socket = context.socket(zmq.PUSH)
logger_socket.connect(config.server_log['external_url'])
tee = logger_socket.send_string

atexit.register(at_exit, [logger_socket])


@app.route('/<file_name>', methods=['GET'])
def get_file(file_name):
    file_name = secure_filename(file_name)
    tee('Sending file: {}'.format(file_name))
    return send_from_directory(INPUT_FILES_DIR, file_name, as_attachment=True)


@app.route('/<file_name>', methods=['POST'])
def post_file(file_name):
    file_name = secure_filename(file_name)
    file_path = os.path.join(RESULT_FILES_DIR, file_name)
    with open(file_path, 'wb') as f:
        f.write(request.data)
    tee('Receiving file: {}'.format(file_name))
    return ''


def main():
    options = {
        'bind': '{}:{}'.format(
            config.server_files['bind_host'],
            config.server_files['bind_port']
        ),
        'workers': config.server_files.get('num_workers', cpu_count()),
        'worker_class': 'gevent'
    }

    tee('Started cc-server-files with pid {}'.format(os.getpid()))

    WebApp(app_module='cc_server.services.files.wsgi', options=options).run()

if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.13479359730412804, 'fraction_numerical': 0.0, 'mean_word_length': 4.6900958466453675, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4639471', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1167, 'n_words': 216}