@csrf_exempt<EOL><INDENT>def jsonrpc(self, request):<DEDENT>
if request.method != "<STR_LIT:POST>":<EOL><INDENT>return HttpResponseNotAllowed(["<STR_LIT:POST>"])<EOL><DEDENT>request_str = request.body.decode('<STR_LIT:utf8>')<EOL>try:<EOL><INDENT>jsonrpc_request = JSONRPCRequest.from_json(request_str)<EOL><DEDENT>except (TypeError, ValueError, JSONRPCInvalidRequestException):<EOL><INDENT>response = JSONRPCResponseManager.handle(<EOL>request_str, self.dispatcher)<EOL><DEDENT>else:<EOL><INDENT>jsonrpc_request.params = jsonrpc_request.params or {}<EOL>jsonrpc_request_params = copy.copy(jsonrpc_request.params)<EOL>if isinstance(jsonrpc_request.params, dict):<EOL><INDENT>jsonrpc_request.params.update(request=request)<EOL><DEDENT>t1 = time.time()<EOL>response = JSONRPCResponseManager.handle_request(<EOL>jsonrpc_request, self.dispatcher)<EOL>t2 = time.time()<EOL>logger.info('<STR_LIT>'.format(<EOL>jsonrpc_request.method, jsonrpc_request_params, t2 - t1))<EOL><DEDENT>if response:<EOL><INDENT>def serialize(s):<EOL><INDENT>return json.dumps(s, cls=DatetimeDecimalEncoder)<EOL><DEDENT>response.serialize = serialize<EOL>response = response.json<EOL><DEDENT>return HttpResponse(response, content_type="<STR_LIT:application/json>")<EOL>
JSON-RPC 2.0 handler.