The ruby one with the -run option is a bit nonintuitive in how it works.<p><pre><code> $ ruby -run -ehttpd . -p8000
</code></pre>
The -r option requires un.rb[1] which is a file full of convenience functions, such as httpd in this example. Classic Ruby.<p>Given that go has popularized long args with a single hyphen (-name etc), it is easy to mistake -run as an option by itself.<p>[1] <a href="https://github.com/ruby/ruby/blob/master/lib/un.rb#L323" rel="nofollow">https://github.com/ruby/ruby/blob/master/lib/un.rb#L323</a>
My favourite is thttpd [1] which is super tiny, battle-tested and actually meant for the job (and only this job). It's available as a package on most Linux distros.<p>Serving a static folder `/static` on port `3000` as user `static-user` and with cache headers set to 60 seconds would go like this:<p><pre><code> thttpd -D -h 0.0.0.0 -p 3000 -d /static -u static-user -l - -M 60
</code></pre>
Even if you've got Python lying around on every Ubuntu server, I still don't get why you wouldn't use something leaner to serve your static files, as long as it's easy to install/configure. Same goes for most of the runtimes in that list.<p>[1] <a href="https://www.acme.com/software/thttpd/" rel="nofollow">https://www.acme.com/software/thttpd/</a>
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.<p>For python3 this is easily remedied.<p><pre><code> python -m http.server -b ::
</code></pre>
On most OS configurations this will listen on both IPv4 and IPv6.<p>Or for when you only need local access:<p><pre><code> python -m http.server -b localhost</code></pre>
(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.
Some of these are multi-liners that can be converted to one-liners. For example I believe "npx" can be used for all the node examples for example "npx http-server -p 6007 ./root"<p>[edit] ahh i see this is called out in the gist comments
$ emrun --port 8000 . # Handles WASM; most others don't.[1]<p>[1] Emscripten's emsdk includes emrun, which actually serves WASM files with the correct MIME type out-of-the-box, unlike the python2 and python3 servers and most others.
Similarly here's a nice list of reverse shell one liners
<a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md" rel="nofollow">https://github.com/swisskyrepo/PayloadsAllTheThings/blob/mas...</a>
How many of these support the partial file loading?
I know that Python don’t (I have been working on support for it).<p>This would make SQLite example supported:
<a href="https://news.ycombinator.com/item?id=27016630" rel="nofollow">https://news.ycombinator.com/item?id=27016630</a>
Only one mention of socat, nothing does ad-hoc nonsense that you probably would never use again like socat.<p>> socat TCP4-LISTEN:50000,fork EXEC:/usr/bin/ifconfig<p>> curl --http0.9 localhost:50000<p>Hmmm, does http v0.9 count?
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.<p>[1] <a href="https://github.com/xonixx/serv" rel="nofollow">https://github.com/xonixx/serv</a><p>[2] <a href="https://medium.com/cmlteam/develop-a-utility-on-graalvm-cc160feafc19" rel="nofollow">https://medium.com/cmlteam/develop-a-utility-on-graalvm-cc16...</a><p>[3] <a href="https://github.com/schollz/croc" rel="nofollow">https://github.com/schollz/croc</a>
It will be a one-liner in Java soon too, once JEP 408 ("simple web server") has landed. In the meantime, this will do:<p><pre><code> jbang webster@gunnarmorling
</code></pre>
This launches Vert.x, publishing the current directory, via the JBang launcher. Source code is here if you want to see what you actually run: <a href="https://github.com/gunnarmorling/jbang-catalog/blob/master/webster.java" rel="nofollow">https://github.com/gunnarmorling/jbang-catalog/blob/master/w...</a>
There is also devd: [1]<p><pre><code> devd .
</code></pre>
[1]: <a href="https://github.com/cortesi/devd" rel="nofollow">https://github.com/cortesi/devd</a>
Anybody has a one-liner allowing CORS (e.g. through options)?<p>That would be utterly convenient to quickly test multithread WASM applications...<p>I'm currently using ExpressJS for that, but it feels overkill..
I wrote a zsh function[1] that runs an http server using ruby, php or python (2 and 3) depending on what's available in the system.<p>[1] <a href="https://github.com/tngranados/dotfiles/blob/0ebdc12f2454061a113846fe8e2079e9b6258068/zshrc#L57-L75" rel="nofollow">https://github.com/tngranados/dotfiles/blob/0ebdc12f2454061a...</a>
I've started using darkhttpd[1] recently, it's simple and compiles quickly to one binary, it supports directory listings and supports range requests.<p><a href="https://github.com/emikulic/darkhttpd" rel="nofollow">https://github.com/emikulic/darkhttpd</a>
I'm a big fan of miniserve[0]. It can do files, directories (including on the fly tgz or zip downloading), authentication and upload<p>[0]: <a href="https://github.com/svenstaro/miniserve" rel="nofollow">https://github.com/svenstaro/miniserve</a>
<a href="https://gist.github.com/willurd/5720255#http-server-nodejs" rel="nofollow">https://gist.github.com/willurd/5720255#http-server-nodejs</a><p>You could do `npx http-server` I believe.
I use busybox httpd to run my blog via cloud run. It’s a fun setup, using a multistage dockerfile to build the static pages and then create a super small busybox image which just serves those pages.
What I use for https:<p><pre><code> $ ruby -r webrick/https -e "WEBrick::HTTPServer.new(Port: 9001, DocumentRoot: '.', SSLEnable: true, SSLCertName: [%w[CN localhost]]).start"</code></pre>
now please also do one for https, no one wants to deal with the cert hassle when they just need a temporary https server for working with some local content.