<commit_before>import requests
from django.http import Http404
from django.shortcuts import render, render_to_response, redirect

# Create your views here.
from django.template import RequestContext

from web.fetch import Fetcher

from settings import LEAN_CLOUD_ID, LEAN_CLOUD_SECRET
import leancloud

# @api_view(('GET',))
# def api_root(request, format=None):
#     return Response({
#         'chairmans': reverse('chairman-list', request=request, format=format),
#     })


def get_index(request):
    # response = requests.get('http://127.0.0.1:8000/api/chairmans/')
    # chairmans = response.json()

    leancloud.init(LEAN_CLOUD_ID, LEAN_CLOUD_SECRET)

    # Chairman = leancloud.Object.extend('Chairman')
    query = leancloud.Query('Chairman')

    chairmans = []

    for chairman in query.add_descending('num').find():
        chairman_view = {}
        chairman_view.type = chairman.get('type')
        chairman_view.href = chairman.get('href')
        chairman_view.id = chairman.get('id')
        chairman_view.title = chairman.get('title')
        chairman_view.img = chairman.get('img')
        chairman_view.name = chairman.get('name')
        chairman_view.num = chairman.get('num')
        chairmans.append(chairman_view)

    return render_to_response('index.html', locals(),
                              context_instance=RequestContext(request))


def fetch(request):
    leancloud.init(LEAN_CLOUD_ID, LEAN_CLOUD_SECRET)

    query = leancloud.Query('Chairman')
<commit_msg>support django 1.11<commit_after>import requests
from django.http import Http404
from django.shortcuts import render, render_to_response, redirect

# Create your views here.
from django.template import RequestContext

from web.fetch import Fetcher

from settings import LEAN_CLOUD_ID, LEAN_CLOUD_SECRET
import leancloud

# @api_view(('GET',))
# def api_root(request, format=None):
#     return Response({
#         'chairmans': reverse('chairman-list', request=request, format=format),
#     })


def get_index(request):
    # response = requests.get('http://127.0.0.1:8000/api/chairmans/')
    # chairmans = response.json()

    leancloud.init(LEAN_CLOUD_ID, LEAN_CLOUD_SECRET)

    # Chairman = leancloud.Object.extend('Chairman')
    query = leancloud.Query('Chairman')

    chairmans = []

    for chairman in query.add_descending('num').find():
        chairman_view = {}
        chairman_view.type = chairman.get('type')
        chairman_view.href = chairman.get('href')
        chairman_view.id = chairman.get('id')
        chairman_view.title = chairman.get('title')
        chairman_view.img = chairman.get('img')
        chairman_view.name = chairman.get('name')
        chairman_view.num = chairman.get('num')
        chairmans.append(chairman_view)

    return render_to_response('index.html', locals())


def fetch(request):
    leancloud.init(LEAN_CLOUD_ID, LEAN_CLOUD_SECRET)

    query = leancloud.Query('Chairman')

{'fraction_non_alphanumeric': 0.12320819112627987, 'fraction_numerical': 0.009897610921501706, 'mean_word_length': 3.7504051863857373, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '598052', 'n_tokens_mistral': 933, 'n_tokens_neox': 934, 'n_words': 169}