[plt-scheme] Scheme program to serve files over HTTP
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)
(loop))
(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
N.