I have found plenty of examples of using the DRF for views bound to models, but none that do just calculations or transformation. i.e. a URL to
/myapp/api/dosomething/ with either a GET method or a POST method that accepts a request, looks at the data in the request, does something and returns a response.
I created three files
/myapp/api/atomicservice1.py
/myapp/api/atomicservice2.py
/myapp/api/atomicservice3.py
class DoSomething:
def process_request(request):requestmethod = request.method
print(‘requestmethod=’, requestmethod)if requestmethod == 'POST': print() print("******************************************") mybody = str(request.body) print("mybody=", mybody) decoded_body = urllib.parse.parse_qs(mybody) print() print("decoded_body=",decoded_body) print("******************************************") print()
how do I create the response to return?