top | item 10322668

Ran: a simple static web server written in Go

46 points| m3ng9i | 10 years ago |github.com

41 comments

order

zytek|10 years 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 ;-)

shazow|10 years ago

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).

saintfiends|10 years ago

For python 3

    python -m http.server

jackyb|10 years ago

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?

skywhopper|10 years ago

The Go server is likely faster, and it's certainly faster to type "ran" than "python -m SimpleHTTPServer".

funkjames|10 years ago

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.

kylecordes|10 years ago

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.

smcleod|10 years ago

Can someone explain to me the advantages of this over using nginx?

danappelxx|10 years ago

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.

grey-area|10 years ago

Have you had a look at caddy?

m3ng9i|10 years ago

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.

ripa|10 years ago

Looks interesting for the niche purpose! I certainly can think of a couple of use cases.

But I don't understand why the build script is written in Python? I think that either you should use a simple shell script or stick to Go.

m3ng9i|10 years ago

Because I like Python more than Bash script, maybe I'll consider using a more gopher way to do the build.

gopowerranger|10 years ago

Go comes with a built in web server that can serve static web pages easily. What's the point of this?

ashark|10 years ago

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)

[1] https://github.com/johnsto/goserve

neurohax|10 years ago

As I understand, the point is: a simple and practical bash command to http-serve the current directory (implemented in Go).

skywhopper|10 years ago

Maybe because you don't have to write it yourself?

    $ go get github.com/m3ng9i/ran && ran