[plt-scheme] Scheme program to serve files over HTTP

From: Noel Welsh (noelwelsh at gmail.com)
Date: Tue Jul 28 06:49:51 EDT 2009

Some notes:

- Surprisingly idiomatic code for your first Scheme program
- In larger programs you'll want to record types in comments.  E.g.:

;; serve : Integer -> (-> Void)
(define (serve port-no)
  (define listener (tcp-listen port-no 5 #t))
  (define (loop)
    (accept-and-handle listener)
  (define t (thread loop))
  (lambda ()
    (kill-thread t)
    (tcp-close listener)))

- There are better ways to determine if a path refers to a directory
or a file. You might use path-only, for example.
- Using quasiquote / xexpr->string is a cleaner way of specifying HTML


Posted on the users mailing list.