A simple web server written in Awk
github.com
github.com
If you enjoy bricolage and you feel like wasting a weekend, I would recommend giving it a try!
[0] https://openwrt.org/docs/guide-user/services/webserver/http....
Edit: ah is this file size? Or does this refer to RAM? Either way, sounds like that's the benefit
> BB httpd can be compiled with only basic features like CGI and ETag and will have only 8Kb
1. Does not implement the GNU networking extensions.
2. Does not implement the GNU array sorting extensions.
3. Does implement the mktime() and strftime extensions.
I see that there is a call to stat() in the code; I didn't know that GNU added this.
Hmmmm
http://localhost:8888/..../..../..../..../..../..../.../.......
Was gonna write:
http://localhost:8888/..../..../..../..../..../..../etc/host...
mypc
These regex substitutions are so easy to bypass :)
Of course, if you're trying to go superminimal anyway, it's not that big a deal to create a server that doesn't even have sensitive data on it. You can make init simply mount a root filesystem that only has busybox and whatever files you want to serve and starts up the httpd process and nothing else. Turn Linux into a unikernel basically. If you compile busybox yourself, you're also able to remove all the subcommands you don't actually need.
> gsub(/\/\.\.+\/?/, "/", request_filename) # avoid directory traversal
source: am "regex expert" >..< (and know how to spell)
https://news.ycombinator.com/item?id=22085459
Pretty printed: https://gist.github.com/tyingq/4e568425e2e68e6390f3105e58878...
The patch is now included in bash 5.2
I recently made a netcat webserver returning only one static response just to have a tiny info page for my new email server, that needs a while true loop but no sleep. I then benchmarked the performance and was very surprised to find that a slow VPS manages [spoiler answer] https://lgms.nl/p/cau/?b64&bY%2FBTsQwDER%2FZbivViDxAxw58Q1pO... Performance graph: https://snipboard.io/Vtn0MO.jpg
socat -v -v TCP-LISTEN:8080,reuseaddr,fork SYSTEM:/some/script
It also has a settable max-children so you can put some bounds on it.I did post another comment where I shared my gawk webserver, but I'm not using socat.
if [ -f /tmp/dontrespawn ]; then break; fi
Instead of sleeping, you can create that file when you want it to stop. But perhaps that'd imply that someone would genuinely use this rather than only developing it as a toyImagine my surprise when I just decided to look into it one day (after finding slightly more complex Awk scripts that did a lot with very little code which piqued my curiosity) and finding this very nice line-oriented DSL that has aged SHOCKINGLY well given how old it is.
I just wish it had interrupt handling of some sort without running a custom fork/patched version
Which is too bad, because the usually shipped gawk extensions also give you fork. If they had separated listen() and accept(), you could actually make a reasonable webserver. See my other comment for an example of what you're limited to.
Edit: There's a CGI plugin for Caddy that looks easy to set up: https://github.com/aksdb/caddy-cgi
python -m http.server 8080
which does not require anything else like socat.If it had been "process some records with awk" that too would have been uninteresting even though it said awk.
nohup python -m http.server 8080 2>/dev/null &The interesting part is the logic and the actual.string processing.