I run my webservers using the Django Python Web Framework.
Django is great because it allows you to easily display variables from a Python backend in the frontend HTML templates.
def view_hierarchy(request):
root = Root()
root.populate("fs_demo")
return render(request, 'base/view_hierarchy.html', {'root':root})
The real challenge here is displaying the Root data structure (containing the recursively mapped directory information) with a template.
A great solution is to make your Django HTML templates similarly recursive. This solution mirrors our initial mapping exactly by using one root template to display a list of the top level files and directories.
The top level template inserts the recursive template for each directory. The same replacement happens in the recursive template for every lower level directory.
The result is a quick way to generate a perfectly preserved representation of any directory hierarchy on your server. See the demo!