def METHOD_NAME(self, attach: bool, *args, **kwargs):
    """
    :param attach: if True, return file as an attachment.
    """
    response: Response = self.make_response(*args, **kwargs)
    response.content_type = self.get_content_type(*args, **kwargs)
    if attach:
        filename = self.get_filename(*args, **kwargs)
        if not filename:
            filename = "file.bin"
        headers = response.headers
        headers.add("Content-Disposition", "attachment", filename=filename)
    self.set_cache_headers(response)
    return response