Live data from Hacker News

Big list of HTTP static server one-liners

gist.github.com

71–80 of 100 posts

Re: Big list of HTTP static server one-liners

#72

Earlier quoted context omitted.

> 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?

> What were they thinking? They were starting back from the 70s. Also one more check for go being alt.history.java, this style is also the standard for Java tooling. And Apple, I think.

Also the standard for PowerShell.

Re: Big list of HTTP static server one-liners

#75

If you have npm installed then simply doing npx serve is very easy

it's also very insecure, because you have no guarantee that the version of `serve` that gets pulled down has been vetted and is verified exploit-free, unless you tell npx exactly which version should be used, at which point things start become less easy and more "having to remember which versions are safe".

Re: Big list of HTTP static server one-liners

#76

Is there a way of doing that in a Windows without installing anything?

Why would you not have things installed already? You're almost guaranteed to have Node or Python or bash (via the linux subsystem for windows) already available if you do any kind of web dev work?

Re: Big list of HTTP static server one-liners

#77
post #7

I'm always surprised that nginx doesn't have a nice way to run as a single-liner command.

I think it makes sense since it is completely driven by its config and adheres to the Unix philosophy of doing one thing well and not clutter the binary with additional stuff for fringe use cases. It would make the now surprisingly simple cli arguments more complex. It should be trivial to write a shell script or alias that templates `root $(pwd);` and invokes `nginx -c /tmp/nginx.conf`

> adheres to the Unix philosophy of doing one thing well and not clutter the binary with additional stuff for fringe use cases

Nginx? Really? "One" thing? Try running `./configure --help` in the Nginx source dir...

Re: Big list of HTTP static server one-liners

#78
post #40

Weird to call these one liners, they're just invocation commands. By that logic, apache is a one-liner.

apache requires a config file. I guess you could put any relevant config into a single line and pipe that through somehow, but it would be a lot more than a single command to define a directory and a port to serve.

PHP was on the list. It also takes a config file (less relavent though to this use)

Re: Big list of HTTP static server one-liners

#80
post #49

Earlier quoted context omitted.

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.

Many examples here in the comments and in the gist itself don't follow it to the letter either, it's easy enough to serve one file. This one might work https://github.com/avleen/bashttpd > socat TCP4-LISTEN:8080 EXEC:/usr/local/bin/bashttpd

> Many examples here in the comments and in the gist itself don't follow it to the letter either, it's easy enough to serve one file.

Curious about what you said, I looked through the gist again and every one of the examples in the gist itself does indeed serve all the files under a path (a "static file server"). Which one are you implying does not?

Post reply on HN