<commit_before>from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.http import HttpResponseRedirect, HttpResponse
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib.auth.decorators import login_required
from django.conf import settings

def register(request):
    if request.method == 'POST':
        form = UserCreationForm(request.POST)
        if form.is_valid():
            new_user = form.save()
            return HttpResponseRedirect("/essay_site/api/v1/?format=json")
    else:
        form = UserCreationForm()
    return render_to_response("registration/register.html", RequestContext(request,{
        'form': form,
        }))

@login_required
def protected_data(request, **params):
    path = params.get("path", None)
    if path is None:
        path = request.GET.get('path', None)
    response = HttpResponse()
    filename_suffix = path.split('.')[-1]
    response['Content-Type'] = 'application/{0}'.format(filename_suffix)
    response['Content-Disposition'] = 'attachment; filename={0}'.format(path)
    response['X-Accel-Redirect'] = '/{0}/{1}'.format(settings.PROTECTED_DATA_ROOT, path)
    return response
<commit_msg>use x-sendfile<commit_after>from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.http import HttpResponseRedirect, HttpResponse
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib.auth.decorators import login_required
from django.conf import settings
import os

def register(request):
    if request.method == 'POST':
        form = UserCreationForm(request.POST)
        if form.is_valid():
            new_user = form.save()
            return HttpResponseRedirect("/essay_site/api/v1/?format=json")
    else:
        form = UserCreationForm()
    return render_to_response("registration/register.html", RequestContext(request,{
        'form': form,
        }))

@login_required
def protected_data(request, **params):
    path = params.get("path", None)
    if path is None:
        path = request.GET.get('path', None)
    response = HttpResponse()
    del response['content-type']
    response['X-Sendfile'] = str(os.path.join(settings.PROTECTED_DATA_ROOT, path))
    return response

{'fraction_non_alphanumeric': 0.11206526406182911, 'fraction_numerical': 0.0030055817947617003, 'mean_word_length': 3.9574468085106385, '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': '204224', 'n_tokens_mistral': 654, 'n_tokens_neox': 640, 'n_words': 154}