<commit_before>import json
import os.path

import logging

from django.conf import settings
from django.http import HttpResponse, HttpResponseServerError, JsonResponse
from django.views import static
from django.views.decorators.csrf import csrf_exempt

from ..experiments.models import Experiment


def ops_lbheartbeat(request):
    return HttpResponse('ok')


def ops_heartbeat(request):
    try:
        # Check the database by counting Experiments
        Experiment.objects.count()
        # TODO: Add checks for other dependencies as we add them
        return HttpResponse('ok')
    except:
        return HttpResponseServerError('database failure')


def ops_version(request):
    VERSION_FN = '%s/version.json' % settings.ROOT
    if os.path.exists(VERSION_FN):
        data = json.load(open(VERSION_FN, 'r'))
    else:
        data = {
            "source": "https://github.com/mozilla/testpilot.git",
            "version": "dev",
            "commit": "dev"
        }
    return JsonResponse(data)


@csrf_exempt
def csp_report(request):
    logger = logging.getLogger('testpilot.csp')
    logger.info('', extra=json.loads(request.body.decode("utf-8")))
    return HttpResponse('ok')


def contribute_json(request):
    return static.serve(request, 'contribute.json', document_root=settings.ROOT)


def privacy(request):
    return static.serve(request, 'legal-copy/privacy-notice.html', document_root=settings.ROOT)


def terms(request):
    return static.serve(request, 'legal-copy/terms-of-use.html', document_root=settings.ROOT)<commit_msg>Fix paths to privacy & terms pages in Django<commit_after>import json
import os.path

import logging

from django.conf import settings
from django.http import HttpResponse, HttpResponseServerError, JsonResponse
from django.views import static
from django.views.decorators.csrf import csrf_exempt

from ..experiments.models import Experiment


def ops_lbheartbeat(request):
    return HttpResponse('ok')


def ops_heartbeat(request):
    try:
        # Check the database by counting Experiments
        Experiment.objects.count()
        # TODO: Add checks for other dependencies as we add them
        return HttpResponse('ok')
    except:
        return HttpResponseServerError('database failure')


def ops_version(request):
    VERSION_FN = '%s/version.json' % settings.ROOT
    if os.path.exists(VERSION_FN):
        data = json.load(open(VERSION_FN, 'r'))
    else:
        data = {
            "source": "https://github.com/mozilla/testpilot.git",
            "version": "dev",
            "commit": "dev"
        }
    return JsonResponse(data)


@csrf_exempt
def csp_report(request):
    logger = logging.getLogger('testpilot.csp')
    logger.info('', extra=json.loads(request.body.decode("utf-8")))
    return HttpResponse('ok')


def contribute_json(request):
    return static.serve(request, 'contribute.json', document_root=settings.ROOT)


def privacy(request):
    return static.serve(request, 'frontend/build/privacy/index.html', document_root=settings.ROOT)


def terms(request):
    return static.serve(request, 'frontend/build/terms/index.html', document_root=settings.ROOT)
{'fraction_non_alphanumeric': 0.11114639568116863, 'fraction_numerical': 0.0006351222610352493, 'mean_word_length': 3.72972972972973, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '4788617', 'n_tokens_mistral': 932, 'n_tokens_neox': 903, 'n_words': 216}