3

tree command on Linux generates visual hierarchy of files and directories, for instance:

/var/log % tree
.
+-- anaconda.ifcfg.log
+-- anaconda.yum.log
+-- audit
+-- boot.log
+-- btmp
+-- ConsoleKit
¦   +-- history
+-- cron
+-- cron-20151227.gz
+-- dmesg
+-- httpd
¦   +-- access_log
¦   +-- access_log-20150329.gz
¦   +-- access_log-20150405
¦   +-- error_log
¦   +-- error_log-20150329.gz
¦   +-- error_log-20150405.gz
¦   +-- error_log-20150412.gz
¦   +-- error_log-20150419
+-- iptables.log
+-- jenkins
¦   +-- jenkins.log
+-- lastlog
+-- maillog

Is there any library for Python that would do something like that, but that would render (decent) HTML?

  • subprocess.call(['tree', '-d', '/path/to/directory']) – Corey Goldberg Jan 25 '17 at 3:34
1

This Stack Overflow questions accepted answer uses the Flask Library and Jinja2 to do exactly what you are asking for using html tables - you could play with the template to get something better looking by setting borders, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.