One Line Web Server
There takes one line to create a web server in a Go program.
http.ListenAndServe(":8080", http.FileServer(http.Dir(".")))
This will serve files from the current directory and below. It protects against
leaving the directory with ../
etc. But it does show dot files. The example
in the documentation can be found at
example-FileServer
The unexpected part here is that the second parameter to ListenAndServe is a
handler. Usually we put a ServeMux there
but anything that looks like an
http.Handler will work. It is also
common to put nil
there so the system uses the default handler.