Big list of HTTP static server one-liners
41–50 of 100 posts
Re: Big list of HTTP static server one-liners
#42Weird to call these one liners, they're just invocation commands. By that logic, apache is a one-liner.
Re: Big list of HTTP static server one-liners
#43Weird to call these one liners, they're just invocation commands. By that logic, apache is a one-liner.
Edit: Someone has posted an Apache example: https://gist.github.com/willurd/5720255#gistcomment-3050599
Re: Big list of HTTP static server one-liners
#44How many of these support the partial file loading? I know that Python don’t (I have been working on support for it). This would make SQLite example supported: https://news.ycombinator.com/item?id=27016630
The node one does, and there is a fork of the python one that does: https://github.com/danvk/RangeHTTPServer/ I know this because I have also been working on something using that magic sqlite-in-browser project :D
Re: Big list of HTTP static server one-liners
#45 nghttpd -v -d /home/user/www -a 127.0.0.1 443 /home/user/demoCA/serverkey.pem /home/user/demoCA/servercert.pemRe: Big list of HTTP static server one-liners
#46The ruby one with the -run option is a bit nonintuitive in how it works. $ ruby -run -ehttpd . -p8000 The -r option requires un.rb[1] which is a file full of convenience functions, such as httpd in this example. Classic Ruby. Given that go has popularized long args with a single hyphen (-name etc), it is easy to mistake -run as an option by itself. [1] https://github.com/ruby/ruby/blob/master/lib/un.rb#L323
> go has popularized long args, with a single hyphen (-name etc) Why did they do that? It took us 20 years to standardize on - for short and -- for long, with occasional finger rage on tar or find, and now this? What were they thinking?
This overall attitude has led to many design decisions in Go, which define the language for better or worse. Statically-linked executables, for instance, contributed more than anything else to Go's popularity as a CLI tool language. Of course, the Bell Labs crowd was already highly skeptical of dynamic linking. See Rob Pike's opinion here: http://harmful.cat-v.org/software/dynamic-linking/
I say it's a hunch, but I think Russ Cox's following comments pretty much demonstrate this attitude against GNUisms and BSDisms: https://github.com/golang/go/issues/2096#issuecomment-660578... https://news.ycombinator.com/item?id=9207316
On the other hand, Russ clearly goes on to say they designed the flags not based on Plan 9 (which only had short single-letter flags), but on Google's gflags library: https://github.com/golang/go/issues/2096#issuecomment-660578...
In short, it's probably both:
- Innate distrust of all things BSD/GNU meant that the original Go team didn't feel they have to honor the established tradition. Just like dynamic linking, they believed that if there is something that GNU does wrong, they don't need to follow it just for the sake of keeping compatibility.
- Positive experience using gflags convinced the team that the gflags approach (single-dash long flags) is the best one.
I personally think they were wrong here. As Russ Cox himself clearly stated in response to all requests for fixing go flags: there are many libraries out there who implement GNU-style flags. What happened in practice is that most Go developers voted with their feet and chose a third-party flag module (even Google's own Kubernetes is using spf13/cobra). In the end, the Go flags package just ended up causing more confusion and didn't solve any of the problems (perceived or real) with GNU flags.
Re: Big list of HTTP static server one-liners
#47Only one mention of socat, nothing does ad-hoc nonsense that you probably would never use again like socat. > socat TCP4-LISTEN:50000,fork EXEC:/usr/bin/ifconfig > curl --http0.9 localhost:50000 Hmmm, does http v0.9 count?
I'd be interested in seeing if you can come up with a socat one-liner that works like a static file server. Would come in handy for many things, but I can't seem to figure out how to make it work.
Re: Big list of HTTP static server one-liners
#48What's a good one that serves gzip assets if they exist? I'm looking for a way to serve a webpack prod build.
Caddy works well and is easy to use and could replace most of these examples, not only for development but for production usage too.
Otherwise go for nginx/apache. Learn the config syntax once, get lifetime worth of value :)
Re: Big list of HTTP static server one-liners
#49Only one mention of socat, nothing does ad-hoc nonsense that you probably would never use again like socat. > socat TCP4-LISTEN:50000,fork EXEC:/usr/bin/ifconfig > curl --http0.9 localhost:50000 Hmmm, does http v0.9 count?
Probably because the example you made doesn't look like a static file server, it seems to execute a specific unix command on incoming request only. The rest of the examples from the gist is proper static file servers. I'd be interested in seeing if you can come up with a socat one-liner that works like a static file server. Would come in handy for many things, but I can't seem to figure out how to make it work.
This one might work https://github.com/avleen/bashttpd
> socat TCP4-LISTEN:8080 EXEC:/usr/local/bin/bashttpd