When setting up a web server for the first time what I always want to do is get a script working that just does basic things like show the contents of the directory on the server. It helps me orient myself to the new language/software.
Here’s my version of the Erlang code block that you can slot into any .yaws page which will show what’s going on and introduce you to a few of the ways that YAWS/Erlang do things.
(code block available from https://gist.github.com/TimP69/5894919)
It’s not meant to be comprehensive, or even very functional. It certainly won’t win any Erlang ‘elegance’ prizes — it probably would be considered long-winded and inefficient by most proficient Erlang programmers.
That misses the point.
If you’re new to Erlang/YAWS life is likely to get really confusing really fast. You may just have spent two hours slamming your head into a brick wall trying to get something done which you consider to be trivial in another language… and just want some concrete examples instead of references to man pages and obscure code snippets.
Hopefully the above will help.
PS: While the above code turns the directories into links that you can click, YAWS will not let you enter those directories by default. You need to edit your yaws.conf file, find the <server> block and add:
dir_listings = true