Some years ago I wrote my own local development web server in a few dozen lines of bash. I could never get nc to work for serving concurrent requests (i.e. html+js+css at the same time) but ncat works great.
It was actually really nice for prototyping with compile-to-js languages like ClojureScript or PureScript, as well as very quickly mocking up little CRUD apps. You’d write little executables to handle all the different HTTP verbs.
i.e. start it up, POST /some/resource, and it’ll try to run ./some/resource/POST if that script exists, then fall back to parent directories. Kind of a cute little hack.
It’s been about 10 days that I setup socat for a test to provide a local web server to connect to with a client cert. Not the simplest anymore, but only one step above with a lot more features.
The best addition is that you can have a TLS connection too using ncat -lvnp 12345 –ssl
You can even specify your certificate and key! Brillant :)
I believe this should be tagged as self-submitted. (Unless I’m just misremembering the effect that has on colors?)
Pleasantly, Plan 9 has the ability to trivially serve an HTTP server as a shell script, such as rc-httpd(8):
https://github.com/9mirrors/plan9front/blob/front/rc/bin/rc-httpd/rc-httpd
You can get TLS without adding any code to your server(s) in Plan 9 as well by using tlssrv(8):
http://man.postnix.pw/9front/8/tlssrv
Some years ago I wrote my own local development web server in a few dozen lines of bash. I could never get
nc
to work for serving concurrent requests (i.e. html+js+css at the same time) butncat
works great.It was actually really nice for prototyping with compile-to-js languages like ClojureScript or PureScript, as well as very quickly mocking up little CRUD apps. You’d write little executables to handle all the different HTTP verbs.
https://github.com/ianthehenry/httprintf
i.e. start it up, POST /some/resource, and it’ll try to run
./some/resource/POST
if that script exists, then fall back to parent directories. Kind of a cute little hack.I’ve enjoyed using Bernstein’s
tcpserver
for this exact thing. It doesn’t do TLS though.https://cr.yp.to/ucspi-tcp/tcpserver.html
If ya wanna use this on macOS, I think you’ll need to replace
-q
with-G
to set the timeout interval. Very cool!Or just omit -q all together.
nc / netcat / ncat, there are so many not that compatible implementations, it’s one of the confusing tools I’ve ever used
python -m http.server
Only works if python is installed…. and for files.
http.server module also supports cgi support, so you could do more than files with it.
It’s been about 10 days that I setup
socat
for a test to provide a local web server to connect to with a client cert. Not the simplest anymore, but only one step above with a lot more features.