It could be even shorter, db> doesn't need to be so complex. There's a bug in write which causes it to not flush output to a port and hence the need to flush directly, and I should be able to append the \r\n directly without doing writec. Was just getting a little tired when I got there :-)
Credit goes to Arc, and also to the C API for SQlite.
I have a web server in the UK which has space on it. I'd be willing to configure Apache as a reverse proxy into an Arc script of your choosing. You can have a little bit of space for free, if that's what you are looking for. If you start killing my server then you'll need to look for something non-free.