human
Can you provide a the Python code you requested given the following:
Complete the below
def allow_api_profiling(handler):

    ''''For API requests decorated with this decorator,
    if \'debug\' is passed in with DEBUG=True,
    it will add a BODY tag to the json response--allowing
    the debug_toolbar to be used.'
    '''
assistant
#Here is the Python code you requested.
    if (not settings.DEBUG):
        return handler
    else:
        def aap_wrapper_fn(request, *args, **kwargs):
            response = handler(request, *args, **kwargs)
            if ((not request.is_ajax()) and (response['Content-Type'] == 'application/json')):
                response.content = ('<body>%s</body>' % response.content)
                response['Content-Type'] = 'text/html'
            return response
        return aap_wrapper_fn