Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.shortcuts import render
- from rest_framework.response import Response
- from rest_framework.decorators import api_view, renderer_classes, permission_classes, authentication_classes
- from rest_framework.renderers import JSONRenderer
- from rest_framework.permissions import IsAuthenticated
- from rest_framework_jwt.authentication import JSONWebTokenAuthentication
- @api_view(['GET'])
- @renderer_classes((JSONRenderer,))
- def public_url_view(request, format=None):
- content = {'user_count': 12}
- return Response(content)
- @api_view(['GET'])
- @renderer_classes((JSONRenderer,))
- @permission_classes((IsAuthenticated,))
- @authentication_classes((JSONWebTokenAuthentication,))
- def protected_url_view(request, format=None):
- content = {'user_count': 98}
- return Response(content)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement