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).
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.
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".
This is great. I had a similar need for some work that I did and created a project that does something similar, albeit with less functionality ( https://github.com/spurin/gowebserver )
I took advantage of the cross os compilation and also provide prebuilt binaries for the various os's. Might be worthwhile doing.
I'll add a stub to the readme to see your project.
Something like this would be especially helpful if it added live reload support. Currently I use https://www.npmjs.com/package/live-server for this, but it requires node, NPM, and including its dependencies amounts to ~1000 files. This is decidedly inconvenient in the context where I use it, which is starting out a class by talking all of the students through installing all of the above.
It would be great to have that functionality bundled into a single file executable, or rather three executables for Windows, Mac, Linux.
In a lot of cases, nginx is overkill. It's also more focused on being a reverse proxy, while ran is more for simply serving static files. Ran also comes with a cli and some other neat features that would be useless in most cases when working with nginx.
What's the disadvantage to being "overkill" that this remedies? nginx is very easy to install, and a static web server configuration is pretty much the default one. Is this faster? Does it use less memory?
I think the main advantage here is that it's a one-binary-file webserver.
Very simple to install and ideal for file sharing among coworkers or similar situations. A modern equivalent of "python -m SimpleHTTPServer".
'python -m SimpleHTTPServer' is actually fairly terrible if you try to use it to share a file amongst coworkers. Try it and you'll see, downloads will actually fail.
It also freaks out if the root dir is blown away, which can be quite common if you're trying to use it with a static site generator.
'python -m SimpleHTTPServer' is great for serving files to yourself but that's about it.
Yes, I've heard caddy during the development of Ran. Caddy is a great web server and has more functionalities than Ran. But I enjoy making things, so Ran is born.
It's handy to have a program, easily compiled for multiple platforms, that can be told to simply serve a given directory, with optional HTTPS support, and no config files or dependencies—just cross-compile to the target arch/OS, scp it over, and run.
Without, you know, having to write it, even if Go's libraries make it fairly easy to do so.
My go-to (haha) for this is Goserve[1]. I'm not sure why I'd switch to this, except that it may now have more eyes on it after today's publicity (it's already got more stars than Goserve—a little advertising goes a long way)
Static file serving is a great tutorial project in Go. I wrote mine (https://github.com/biorisk/httpfolder) to include a file upload option too, but did not add some of the nicer features, e.g., https, in your project.
Not sure why you think this server was written to integrate into apps. If you can't think of a use for it, that's fine. But lots of other people do have uses for simple static web servers. Including people who don't have the knowledge, time, or patience to hand code a 20 line Go program every time they want to use one.
By integrate I meant interacting with your program, whatever that may be. With the go server, you get everything this program has without the concern of the code going stale or dying should the author abandon it.
Not necessarily. In addition, this kind of program can be really useful for development.
I use "python3 -m http.server" a lot when I'm just testing a bit of HTML/JS and don't want to setup a whole virtual host within Nginx/Apache. It just starts a static file server, on any platform.
Anyway, kudos for making a Go project shipped, which I fail to accomplish for several months now ;-)