|
|
@@ -132,3 +132,22 @@ def linkedin(request):
|
|
|
context = {'title': 'linkedin Example','userdata': userinfo}
|
|
|
return render(request, 'hackathon/linkedin.html', context)
|
|
|
|
|
|
+class JSONResponse(HttpResponse):
|
|
|
+ """
|
|
|
+ An HttpResponse that renders its content into JSON.
|
|
|
+ """
|
|
|
+ def __init__(self, data, **kwargs):
|
|
|
+ content = JSONRenderer().render(data)
|
|
|
+ kwargs['content_type'] = 'application/json'
|
|
|
+ super(JSONResponse, self).__init__(content, **kwargs)
|
|
|
+
|
|
|
+@csrf_exempt
|
|
|
+def snippet_list(request):
|
|
|
+ """
|
|
|
+ List all code snippets, or create a new snippet.
|
|
|
+ """
|
|
|
+ if request.method == 'GET':
|
|
|
+ snippets = Snippet.objects.all()
|
|
|
+ serializer = SnippetSerializer(snippets, many=True)
|
|
|
+ return JSONResponse(serializer.data)
|
|
|
+
|