def clean_path(path):
    """ remove index.html from end of a path, add / if not at beginning """

    path = path.split("index.html")[0]
    if not path.startswith("/"): path = "/" + path
    if not path.endswith("/"): path += "/"
    return path