Live data from Hacker News

Big list of HTTP static server one-liners

gist.github.com

51–60 of 100 posts

Re: Big list of HTTP static server one-liners

#51
My take on this [1]. Explanation article [2]. In fact the use-case I addressed was slightly different (explained in the article) and later I found the similar tool [3] which probably is more powerful.

[1] https://github.com/xonixx/serv

[2] https://medium.com/cmlteam/develop-a-utility-on-graalvm-cc16...

[3] https://github.com/schollz/croc

Re: Big list of HTTP static server one-liners

#52

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?

My hunch is that Rob Pike, Ken Thompson, Russ Cox and the other Bell Labs alumni behind Go disliked GNU getopt-style flags, like they dislike a lot of other GNU and BSD decisions that "contaminate" the original philosophy behind Unix. 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…

Damn, a constructive and sourced answer. I wish I could upvote that twice.

Re: Big list of HTTP static server one-liners

#54

(2013). There are many comments since then providing more alternatives, many of which didn’t exist back in 2013, but the article itself hasn’t been touched since 2013-07-07.

While the author hasn’t updated the main link, it’s clear he checked up on the article until atleast 2017: one of the comments originally was a base64 encoded string, and the author edited and deleted it so that no one would run random base64 strings off the internet.

Re: Big list of HTTP static server one-liners

#55

Anybody has a one-liner allowing CORS (e.g. through options)? That would be utterly convenient to quickly test multithread WASM applications... I'm currently using ExpressJS for that, but it feels overkill..

You can try serverino (https://github.com/mmazzarolo/serverino) with the --cors option.

Re: Big list of HTTP static server one-liners

#57

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

Of course this requires internet access. It is also arguably less secure as it is downloading code from the internet and means that you are trusting the latest code from a handful of people https://www.npmjs.com/package/serve

Re: Big list of HTTP static server one-liners

#58
Note that a lot of these bind to 0.0.0.0 by default. This has caused me surprises in the past as I was failing to connect to a host that is available over IPv6. Sometimes it was even intermittent as I would sometime resolve to the IPv4 and sometimes get the IPv6 and fail.

For python3 this is easily remedied.

    python -m http.server -b ::
On most OS configurations this will listen on both IPv4 and IPv6.

Or for when you only need local access:

    python -m http.server -b localhost

Re: Big list of HTTP static server one-liners

#59

The 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

Permalink: https://github.com/ruby/ruby/blob/v3_0_1/lib/un.rb#L323

(Tip: can hit “y” on GitHub to change the URL to a revision-based permalink)

Re: Big list of HTTP static server one-liners

#60

Note that a lot of these bind to 0.0.0.0 by default. This has caused me surprises in the past as I was failing to connect to a host that is available over IPv6. Sometimes it was even intermittent as I would sometime resolve to the IPv4 and sometimes get the IPv6 and fail. For python3 this is easily remedied. python -m http.server -b :: On most OS configurations this will listen on both IPv4 and IPv6. Or for when you…

For the use cases of most of that software list, they should actually listen to localhost (127.0.0.1 and ::1) only, because security. Listening on every IPv6 interface, which might be exposed directly on the IPv6 internet, is even a worse idea.
Post reply on HN