6 ms·
Ran: a simple static web server written in Go
- ripa 11y agoLooks 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 11y agoBecause I like Python more than Bash script, maybe I'll consider using a more gopher way to do the build.
- smcleod 11y agoCan someone explain to me the advantages of this over using nginx?
- danappelxx 11y agoIn 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.
- robbles 11y agoWhat'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?
- athrun 11y agoI 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".
- m3ng9i 11y agoYes, "python -m SimpleHTTPServer" is too slow.
- omginternets 11y agoToo slow for what?
- nilliams 11y ago'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.
- grey-area 11y agoHave you had a look at caddy?
- m3ng9i 11y agoYes, 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.
- grey-area 11y agoThought you might be interested in it as it is similar, though more focussed on being a reverse proxy in front of other processes. Good luck with Ran.
- shazow 11y ago+1 to Caddy, here's a handy link: https://github.com/mholt/caddy https://github.com/mholt/caddy Very configurable but also very easy to get started. $ caddy browse and off you go.
- funkjames 11y agoThis 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 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.
- jorams 11y agoIf you're looking for a quick tool to serve static files from a directory, darkhttpd[1] is also pretty good. [1]: https://www.unix4lyfe.org/darkhttpd/ https://www.unix4lyfe.org/darkhttpd/
- gopowerranger 11y agoGo comes with a built in web server that can serve static web pages easily. What's the point of this?
- ojanik 11y agoI was wandering the same thing. It takes only few lines to set this one up: https://golang.org/pkg/net/http/#FileServer https://golang.org/pkg/net/http/#FileServer
- beefsack 11y agoSpecifically: https://golang.org/pkg/net/http/#FileServer https://golang.org/pkg/net/http/#FileServer
- ashark 11y agoIt'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 https://github.com/johnsto/goserve
- gopowerranger 11y agoSo 20 or so lines of code is too tough? How much work is involved integrating this server into an app?
- skywhopper 11y agoNot 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.
- kid0m4n 11y agoPlug: https://github.com/kidoman/serve https://github.com/kidoman/serve Gets the job done!
- zytek 11y agoIf 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 ;-)
- jackyb 11y agoI 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?
- jeffreyparker 11y agoIt 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.
- skywhopper 11y agoThe Go server is likely faster, and it's certainly faster to type "ran" than "python -m SimpleHTTPServer".
- masklinn 11y ago> 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`.
- junke 11y ago> ... 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".
- kylecordes 11y agoSomething like this would be especially helpful if it added live reload support. Currently I use https://www.npmjs.com/package/live-server 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.
- melling 11y agoI use Google's App Engine which has live reload on the development server. My main page is static but I've got one page that's a bit more complicated: http://www.h4labs.com http://www.h4labs.com http://www.h4labs.com/dev/ios/swift.html http://www.h4labs.com/dev/ios/swift.html
- kzahel 11y agoRelated, but requires no command-line to run or setup. https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb https://chrome.google.com/webstore/detail/web-server-for-chr... (MIT License)