from django.shortcuts import render
from django.http import HttpResponse

def index(request):
    return HttpResponse('success!\n')

@@ -65,16 +65,57 @@
 Response
+, JsonResponse%0A%0Afrom api.models import *%0A
 %0A%0Adef in
@@ -166,8 +166,675 @@
 ss!%5Cn')%0A
+%0Adef _success(stat, data):%0A    return JsonResponse(%7B 'stat': stat %7D + data)%0A%0Adef _fail(stat, error_msg):%0A    return JsonResponse(%7B 'stat': stat, 'error': error_msg %7D)%0A%0A%0Adef get_article_body(request):%0A    query = request.GET.dict()%0A    match = Article.objects.filter(**query)%0A%0A    if len(match) == 0: return _fail(404, 'article not found')%0A    if len(match) %3E 1: return _fail(400, 'multiple articles found')%0A%0A    obj = match%5B0%5D%0A    body = %5B''%5D * len(obj.setence_set)%0A    for sentence in obj.sentence_set:%0A        body%5Bsentence.position%5D = sentence.content%0A%0A    ret = %7B 'title': obj.title, 'author': obj.author %7D%0A    ret%5B'content'%5D = body%0A    return _success(200, ret)%0A

add view method