def METHOD_NAME(func):
    @functools.wraps(func)
    def decorated_func(*args, **kwargs):
        if (not app.debug and
                # This header cannot be set by external requests.
                # https://cloud.google.com/tasks/docs/creating-appengine-handlers?hl=en#reading_app_engine_task_request_headers
                not flask.request.headers.get('X-AppEngine-QueueName')):
            return ('External requests not allowed', HTTPStatus.FORBIDDEN)
        return func(*args, **kwargs)
    return decorated_func