Using Django and Django REST Framework, I am trying to write a GET request which when called will return a JSON file located on the server. What is the best way to accomplish this?
class MyView(APIView):
def get(self, request):
...
# I get a filepath to 'somefile.json'
my_filepath = "/Users/me/Desktop/somefile.json"
...
# What do I do in order to return 'somefile.json'?
return Response(somefile.json)
EDIT
I do not want to return the contents of somefile.json. I want to return the file itself.
return FileResponse(my_filepath, 'rb')did the trick