<commit_before>import logging

logger = logging.getLogger('bellman.views')

from django.http import HttpResponse, HttpResponseBadRequest  # JsonResponse
from django.views.decorators.csrf import csrf_exempt
from django.conf import settings

from bellman import Bellman
# Create your views here.


@csrf_exempt
def require_slack_token(slack_token):
    def decorator(func):
        def handler(request, *args, **kwargs):
            if slack_token == request.POST.get('token'):
                return func(request, *args, **kwargs)
            return HttpResponseBadRequest('Invalid or missing slack token.')
        return handler
    return decorator


@require_slack_token(settings.SLACK_TOKEN)
def announce(request):
    logger.debug('POST from northhq slack')
    logger.debug(request.POST)
    app = Bellman(
        text=request.POST['text'],
        user_name=request.POST['user_name'],
        user_id=request.POST['user_id'])
    app.execute()
    return HttpResponse(app.get_response())
<commit_msg>move to correct lcoation<commit_after>import logging

logger = logging.getLogger('bellman.views')

from django.http import HttpResponse, HttpResponseBadRequest  # JsonResponse
from django.views.decorators.csrf import csrf_exempt
from django.conf import settings

from bellman import Bellman
# Create your views here.


def require_slack_token(slack_token):
    def decorator(func):
        @csrf_exempt
        def handler(request, *args, **kwargs):
            if slack_token == request.POST.get('token'):
                return func(request, *args, **kwargs)
            return HttpResponseBadRequest('Invalid or missing slack token.')
        return handler
    return decorator


@require_slack_token(settings.SLACK_TOKEN)
def announce(request):
    logger.debug('POST from northhq slack')
    logger.debug(request.POST)
    app = Bellman(
        text=request.POST['text'],
        user_name=request.POST['user_name'],
        user_id=request.POST['user_id'])
    app.execute()
    return HttpResponse(app.get_response())

{'fraction_non_alphanumeric': 0.10024570024570024, 'fraction_numerical': 0.0, 'mean_word_length': 3.7348837209302324, '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': '4286850', 'n_tokens_mistral': 591, 'n_tokens_neox': 582, 'n_words': 139}