<commit_before>from django.shortcuts import render, redirect
from django.http import HttpResponse
from django.urls import reverse
from django.contrib.auth.decorators import login_required
from rest_framework.renderers import TemplateHTMLRenderer
import urllib2, base64
import json
from rest_framework.views import APIView
from django.template.response import TemplateResponse
import os

def index(index):
    return redirect("author-add")

class PostsView(APIView):
    '''
    '''
    username = 'dogordie'
    # username = 'admin'
    # password='<PASSWORD>'
    password = os.environ.get('FRONTEND_PASSWORD')
    # host = 'http://localhost:8000/'
    host = 'http://winter-resonance.herokuapp.com/'
    def get(self, request):
        url = self.host + 'frontend/posts/'
        req = urllib2.Request(url)
        base64string = base64.b64encode('%s:%s' % (self.username, self.password))
        req.add_header("Authorization", "Basic %s" % base64string)
        serialized_data = urllib2.urlopen(req).read()
        posts = json.loads(serialized_data)
        return render(request, "posts.html", {"posts":posts['posts']})

class AuthorPostsView(APIView):
    '''
    '''
    username = 'dogordie'
    # username = 'admin'
    # password='<PASSWORD>'
    password = os.environ.get('FRONTEND_PASSWORD')
    # host = 'http://localhost:8000/'
    host = 'http://winter-resonance.herokuapp.com/'
    def get(self, request):
        url = self.host + 'frontend/author/posts/'
        req = urllib2.Request(url)
        base64string = base64.b64encode('%s:%s' % (self.username, self.password))
        req.add_header("Authorization", "Basic %s" % base64string)
        serialized_data = urllib2.urlopen(req).read()
        posts = json.loads(serialized_data)
        return render(request, "author-posts.html", {"posts":posts['posts']})

class FriendView(APIView):
    username = 'dogordie'
    password = <PASSWORD>('FRONTEND_PASSWORD')
    username = 'admin'
    password = '<PASSWORD>'
    host = 'http://winter-resonance.herokuapp.com/'
    host = 'http://localhost:8000/'
    def get(self, request):
        user = request.user.username
        
        print str(user.username)
        url = self.host + 'friends/' + str(user.username)
        req = urllib2.Request(url)
        base64string = base64.b64encode('%s:%s' % (self.username, self.password))
        req.add_header("Authorization", "Basic %s" % base64string)
        serialized_data = urllib2.urlopen(req).read()
        friends = json.loads(serialized_data)
        return render(request, "friends.html", {"friends":friends})
<commit_msg>Fixing incorrect variable usage.<commit_after>from django.shortcuts import render, redirect
from django.http import HttpResponse
from django.urls import reverse
from django.contrib.auth.decorators import login_required
from rest_framework.renderers import TemplateHTMLRenderer
import urllib2, base64
import json
from rest_framework.views import APIView
from django.template.response import TemplateResponse
import os

def index(index):
    return redirect("author-add")

class PostsView(APIView):
    '''
    '''
    username = 'dogordie'
    # username = 'admin'
    # password='<PASSWORD>'
    password = <PASSWORD>('FRONTEND_PASSWORD')
    # host = 'http://localhost:8000/'
    host = 'http://winter-resonance.herokuapp.com/'
    def get(self, request):
        url = self.host + 'frontend/posts/'
        req = urllib2.Request(url)
        base64string = base64.b64encode('%s:%s' % (self.username, self.password))
        req.add_header("Authorization", "Basic %s" % base64string)
        serialized_data = urllib2.urlopen(req).read()
        posts = json.loads(serialized_data)
        return render(request, "posts.html", {"posts":posts['posts']})

class AuthorPostsView(APIView):
    '''
    '''
    username = 'dogordie'
    # username = 'admin'
    # password='<PASSWORD>'
    password = <PASSWORD>('FRONTEND_PASSWORD')
    # host = 'http://localhost:8000/'
    host = 'http://winter-resonance.herokuapp.com/'
    def get(self, request):
        url = self.host + 'frontend/author/posts/'
        req = urllib2.Request(url)
        base64string = base64.b64encode('%s:%s' % (self.username, self.password))
        req.add_header("Authorization", "Basic %s" % base64string)
        serialized_data = urllib2.urlopen(req).read()
        posts = json.loads(serialized_data)
        return render(request, "author-posts.html", {"posts":posts['posts']})

class FriendView(APIView):
    username = 'dogordie'
    password = <PASSWORD>('FRONTEND_PASSWORD')
    username = 'admin'
    password = '<PASSWORD>'
    host = 'http://winter-resonance.herokuapp.com/'
    def get(self, request):
        username = request.user.username
        
        url = self.host + 'friends/' + str(username)
        req = urllib2.Request(url)
        base64string = base64.b64encode('%s:%s' % (username, self.password))
        req.add_header("Authorization", "Basic %s" % base64string)
        serialized_data = urllib2.urlopen(req).read()
        friends = json.loads(serialized_data)
        return render(request, "friends.html", {"friends":friends})

{'fraction_non_alphanumeric': 0.13996889580093314, 'fraction_numerical': 0.01671850699844479, 'mean_word_length': 3.420103092783505, 'pattern_counts': {'":': 6, '<': 13, '<?xml version=': 0, '>': 13, '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': '945742', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1596, 'n_words': 313}