1. 16
  1.  

  2. 2

    I find this to be rather curious, and wonder how far this could be taken… Suppose we had a table pending_requests

    CREATE TABLE pending_requests (
       id int AUTO_INCREMENT,
       fd int,
       path text,
       accept_header text
    )
    

    where fd is the socket file descriptor, and we treat this as a queue. So, we then have another set of threads that drain these requests, rendering based on path. Presumably, we can’t do that much dynamic content generation, but the file descriptor can still be written to. So, if it was a static site:

    CREATE TABLE pages (
       id int AUTO_INCREMENT,
       path text,
       body text
    )
    

    The “worker” thread does:

    SELECT r.fd, CASE WHEN p.id > 0 THEN 200 ELSE 404 END status, 
                   p.path, p.body FROM pending_requests r 
    LEFT OUTER JOIN pages p ON p.path = r.path 
    WHERE p.path = $1
    

    Or, something, and writes the request to fd. Of course, this doesn’t work with restarts, so the table must be flushed on startup, and there’s a bunch of other edge cases to contend with… Do it all in a TX and delete to remove the pending request.

    Markdown could be supported by linking one of the C based markdown libraries and setting up an extension. Then running markdown(body) if appropriate.

    So, then there’s the question of dynamic content, like, especially in regards to path based URLs with variable ids and such. SQLite has a number of text functions, so I’m pretty confident that some stuff could be done, especially in regards to routing to collect parameters to query against, but I’m having trouble figuring out a way in which to dynamically render templates with content coming from the database. My guess is that this could be done with Recursive Common Table Expression queries and a lot of text munging, but I have no real clue how to use them to get that to work, nor do I understand the limitations of what you could express using data from within the database to do it….

    But, the only external requirement is a web server that can query SQLite.