Re:Ran: a simple static web server written in Go
by gopowerranger on Saturday October 03, 2015 @07:55AM
(#10323538)
Go comes with a built in web server that can serve static web pages easily. What's the point of this?
[ Parent
| on HN ]
Re:Ran: a simple static web server written in Go
by ashark on Saturday October 03, 2015 @09:32AM
(#10323816)
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)
Re:Ran: a simple static web server written in Go
by biomcgary on Saturday October 03, 2015 @11:38AM
(#10324245)
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.
Re:Ran: a simple static web server written in Go
by gopowerranger on Saturday October 03, 2015 @09:52AM
(#10323881)
So 20 or so lines of code is too tough? How much work is involved integrating this server into an app?
Re:Ran: a simple static web server written in Go
by skywhopper on Saturday October 03, 2015 @10:32AM
(#10324014)
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.
Re:Ran: a simple static web server written in Go
by gopowerranger on Saturday October 03, 2015 @12:34PM
(#10324412)
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.
Re:Ran: a simple static web server written in Go
by beefsack on Saturday October 03, 2015 @09:27AM
(#10323801)
Specifically: https://golang.org/pkg/net/http/#FileServer
Re:Ran: a simple static web server written in Go
by ojanik on Saturday October 03, 2015 @08:37AM
(#10323626)
I was wandering the same thing. It takes only few lines to set this one up: https://golang.org/pkg/net/http/#FileServer
Re:Ran: a simple static web server written in Go
by neurohax on Saturday October 03, 2015 @12:40PM
(#10324426)
As I understand, the point is: a simple and practical bash command to http-serve the current directory (implemented in Go).
Re:Ran: a simple static web server written in Go
by gopowerranger on Saturday October 03, 2015 @01:43PM
(#10324665)
So everything Go already does but in bash.
Re:Ran: a simple static web server written in Go
by skywhopper on Saturday October 03, 2015 @09:37AM
(#10323834)
Maybe because you don't have to write it yourself?
$ go get github.com/m3ng9i/ran && ran
Re:Ran: a simple static web server written in Go
by gopowerranger on Saturday October 03, 2015 @09:54AM
(#10323890)
How much work is involved integrating this server into your application versus writing 20 lines of Go code? Or less. Maybe more.
Re:Ran: a simple static web server written in Go
by conradk on Saturday October 03, 2015 @10:47AM
(#10324060)
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.
Re:Ran: a simple static web server written in Go
by gopowerranger on Saturday October 03, 2015 @12:32PM
(#10324400)
So just like go except with benefits.