Hacker News new | ask | show | jobs
by zytek 3910 days ago
If in need of serving current dir over HTTP I use

    python -m SimpleHTTPServer
works everywhere I need it to work.

Anyway, kudos for making a Go project shipped, which I fail to accomplish for several months now ;-)

4 comments

I love SimpleHTTPServer. I use it 80% of the time. One downside is that it's single-threaded, so if you have multiple people who need to fetch stuff from your server it can get pretty painful.

I was helping run a programming workshop last week and I wrote my own tiny concurrent server in Go but in the future I think I'll just use Caddy (https://github.com/mholt/caddy).

For python 3

    python -m http.server
I don't know why but it often takes a really long time for me to reload the web page using Python 2 and 3 on Linux. Anybody has similar experience?
It can only serve one connection at a time, so if you're using it to serve a file download or have multiple users accessing it simultaneously it'll hang for all other clients.
The Go server is likely faster, and it's certainly faster to type "ran" than "python -m SimpleHTTPServer".
> The Go server is likely faster

Which is not usually relevant if you just want to share a file over local HTTP. If you need a production-level HTTP server, you're not using either.

> it's certainly faster to type "ran" than "python -m SimpleHTTPServer".

If you're smart enough to compile ran and put it on your PATH, you're probably smart enough to create an alias for `python -m SimpleHTTPServer`.

> ... faster ... faster

It is faster to use an existing tool (python or another one) than rewriting a 2K LOC one. This is great for learning Go but the compounded time "lost" with a "slow" python server is nothing compared to the time this tool will require in development, debugging and maintenance over the years. As anyone else, I am subject to NIH and I can understand why writing one's own library is interesting by itself. Please don't invent weak excuses like "ran is faster to type".