<commit_before>from flask import Flask, request
from celery.local import PromiseProxy
from .config import Config
import requests
import json
from jwt.algorithms import RSAAlgorithm
import jwt


class MsBot:
    def __init__(self, host=None, port=None, debug=None, app_client_id=None):
        self.processes = []
        config = Config()
        self.host = config.get_config(host, 'HOST', root='flask')
        self.port = config.get_config(port, 'PORT', root='flask')
        self.debug = config.get_config(debug, 'DEBUG', root='flask')
        self.app_client_id = config.get_config(app_client_id, 'APP_CLIENT_ID')

        self.app = Flask(__name__)

        @self.app.route('/api/messages', methods=['POST'])
        def message_post():
            valid_token = self.verify_token(request)

            if valid_token:
                json_message = request.get_json()

                self.app.logger.info('message.headers: {}'.format(json.dumps(request.headers.__dict__)))
                self.app.logger.info('message.body: {}'.format(json_message))

                for process in self.processes:
                    if isinstance(process, PromiseProxy):
                        self.app.logger.info('Processing task {} asynchronously.'.format(type(process).__name__))
                        process.delay(json_message)
                    elif callable(process):
                        self.app.logger.info('Processing task {} synchronously.'.format(process.__name__))
                        process(json_message)
                return "Success"

    def add_process(self, process):
        self.processes.append(process)

    def run(self):<commit_msg>Placed headers in a dict<commit_after>from flask import Flask, request
from celery.local import PromiseProxy
from .config import Config
import requests
import json
from jwt.algorithms import RSAAlgorithm
import jwt


class MsBot:
    def __init__(self, host=None, port=None, debug=None, app_client_id=None):
        self.processes = []
        config = Config()
        self.host = config.get_config(host, 'HOST', root='flask')
        self.port = config.get_config(port, 'PORT', root='flask')
        self.debug = config.get_config(debug, 'DEBUG', root='flask')
        self.app_client_id = config.get_config(app_client_id, 'APP_CLIENT_ID')

        self.app = Flask(__name__)

        @self.app.route('/api/messages', methods=['POST'])
        def message_post():
            valid_token = self.verify_token(request)

            if valid_token:
                json_message = request.get_json()

                self.app.logger.info('message.headers: {}'.format(json.dumps(request.headers)))
                self.app.logger.info('message.body: {}'.format(json_message))

                for process in self.processes:
                    if isinstance(process, PromiseProxy):
                        self.app.logger.info('Processing task {} asynchronously.'.format(type(process).__name__))
                        process.delay(json_message)
                    elif callable(process):
                        self.app.logger.info('Processing task {} synchronously.'.format(process.__name__))
                        process(json_message)
                return "Success"

    def add_process(self, process):
        self.processes.append(process)

    def run(self):
{'fraction_non_alphanumeric': 0.11414020371479928, 'fraction_numerical': 0.0, 'mean_word_length': 2.393292682926829, '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': '220041', 'n_tokens_mistral': 939, 'n_tokens_neox': 894, 'n_words': 183}