aboutsummaryrefslogtreecommitdiffstats
path: root/examples/pygments_api
diff options
context:
space:
mode:
Diffstat (limited to 'examples/pygments_api')
-rw-r--r--examples/pygments_api/views.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/examples/pygments_api/views.py b/examples/pygments_api/views.py
index ffea60ae..852b6730 100644
--- a/examples/pygments_api/views.py
+++ b/examples/pygments_api/views.py
@@ -61,7 +61,7 @@ class PygmentsRoot(View):
Return a list of all currently existing snippets.
"""
unique_ids = [os.path.split(f)[1] for f in list_dir_sorted_by_ctime(HIGHLIGHTED_CODE_DIR)]
- return [reverse('pygments-instance', args=[unique_id]) for unique_id in unique_ids]
+ return Response([reverse('pygments-instance', args=[unique_id]) for unique_id in unique_ids])
def post(self, request):
"""
@@ -81,7 +81,8 @@ class PygmentsRoot(View):
remove_oldest_files(HIGHLIGHTED_CODE_DIR, MAX_FILES)
- return Response(status.HTTP_201_CREATED, headers={'Location': reverse('pygments-instance', args=[unique_id])})
+ self.headers['Location'] = reverse('pygments-instance', args=[unique_id])
+ return Response(status=status.HTTP_201_CREATED)
class PygmentsInstance(View):
@@ -89,7 +90,7 @@ class PygmentsInstance(View):
Simply return the stored highlighted HTML file with the correct mime type.
This Resource only renders HTML and uses a standard HTML renderer rather than the renderers.DocumentingHTMLRenderer class.
"""
- renderers = (HTMLRenderer,)
+ renderer_classes = (HTMLRenderer,)
def get(self, request, unique_id):
"""
@@ -98,7 +99,7 @@ class PygmentsInstance(View):
pathname = os.path.join(HIGHLIGHTED_CODE_DIR, unique_id)
if not os.path.exists(pathname):
return Response(status.HTTP_404_NOT_FOUND)
- return open(pathname, 'r').read()
+ return Response(open(pathname, 'r').read())
def delete(self, request, unique_id):
"""
@@ -107,5 +108,5 @@ class PygmentsInstance(View):
pathname = os.path.join(HIGHLIGHTED_CODE_DIR, unique_id)
if not os.path.exists(pathname):
return Response(status.HTTP_404_NOT_FOUND)
- return os.remove(pathname)
+ return Response(os.remove(pathname))