<commit_before>from django.contrib.sites.shortcuts import get_current_site

from utils import jsonify


class ApiErrorHandler(object):
    """ Return API 500-level errors as JSON. """
    def process_exception(self, request, exception):
        if request.path.startswith('/api/'):
            return jsonify({
                'status': 'error',
                'message': exception.message,
            }, status=500)


class SiteMiddleware(object):
    """ Toggle urls based on site.
    """
    def process_request(self, request):
        site = get_current_site(request)
        print site
        if site.name == 'API':
            request.urlconf = 'municipal_finance.urls'
        else:
            request.urlconf = 'scorecard.urls'<commit_msg>Remove debug print.<commit_after>from django.contrib.sites.shortcuts import get_current_site

from utils import jsonify


class ApiErrorHandler(object):
    """ Return API 500-level errors as JSON. """
    def process_exception(self, request, exception):
        if request.path.startswith('/api/'):
            return jsonify({
                'status': 'error',
                'message': exception.message,
            }, status=500)


class SiteMiddleware(object):
    """ Toggle urls based on site.
    """
    def process_request(self, request):
        site = get_current_site(request)
        if site.name == 'API':
            request.urlconf = 'municipal_finance.urls'
        else:
            request.urlconf = 'scorecard.urls'
{'fraction_non_alphanumeric': 0.11066398390342053, 'fraction_numerical': 0.008048289738430584, 'mean_word_length': 2.4377880184331797, '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': '6791946', 'n_tokens_mistral': 425, 'n_tokens_neox': 414, 'n_words': 101}