def get(self): """ 获取主机列表 """ host_list = Host.list() host_list = [host.to_json() for host in host_list] return APIResponse(code=0, data=host_list)
def get_hosts(): hosts = Host.list() hosts = [h.to_json() for h in hosts] if hosts else None return hosts