example.scm from fcgi added by ohwow on Thu May 19 13:19:08 2011

(require-extension fastcgi)

(fcgi-accept-loop
  8080
  0
  (lambda (in out err env)
    (out "Content-type: text/html\r\n\r\n")
    (out "<html><body>")

    ;; Look up the value of the SERVER_NAME environment variable
    ;; and print it.
    (out "<b>This server is: </b>")
    (out (env "SERVER_NAME" "[unknown]"))
    (out "<br><br>")

    ;; Print the name and value of every environment variable.
    (out "<table><tr><th align=\"left\">Variable</th>")
    (out "<th align=\"left\")>Value</th></tr>")
    (for-each
     (lambda (k/v)
       (out "<tr><td>")
       (out (car k/v))
       (out "</td><td>")
       (out (cdr k/v))
       (out "</td></tr>"))
     (env))
    (out "</table>")
    (out "<br><br>")

    ;; Print POST data, if there is any.
    (let ((post-data (fcgi-get-post-data in env)))
      (when post-data
        (out "The following post data was given:<br>")
        (out post-data)))
    (out "</body></html>")))