def render(args):
    """
    Helper that helps us render the REST Api responses.
    :param args:
    :return:
    """
    query = database.session_query(Endpoint)\
        .options(joinedload(Endpoint.certificate))\
        .options(joinedload(Endpoint.source))
    filt = args.pop("filter")

    if filt:
        terms = filt.split(";")
        term = f"%{terms[1]}%"
        if "active" in filt:  # this is really weird but strcmp seems to not work here??
            query = query.filter(Endpoint.active == truthiness(terms[1]))
        elif "port" in filt:
            if terms[1] != "null":  # ng-table adds 'null' if a number is removed
                query = query.filter(Endpoint.port == terms[1])
        elif "ciphers" in filt:
            query = query.filter(Cipher.name == terms[1])
        elif "source" in filt:
            query = query.filter(Endpoint.source.has(Source.label.like(term.lower())))
        else:
            query = database.filter(query, Endpoint, terms)

        if terms[0] == "name":
            alias_query = Endpoint.query.filter(
                Endpoint.aliases.any(EndpointDnsAlias.alias.ilike(f"%{terms[1]}%")))
            query = query.union(alias_query)

    return database.sort_and_page(query, Endpoint, args)

    Helper that helps us render the REST Api responses.
    :param args:
    :return:
    
lemur/endpoints/service.py