remove external state error

This commit is contained in:
interp 2002-09-14 15:18:12 +00:00
parent 84a92fb2b5
commit 93b2ab23b1
1 changed files with 34 additions and 23 deletions

View File

@ -5,11 +5,21 @@
httpd-responses
crlf-io)
(begin
(define (main req)
(define *data* '())
(define (read-data)
(let ((news-input (open-input-file "news.txt")))
(let loop ()
(let ((next-line (read-crlf-line news-input)))
(let loop ((next-line (read-crlf-line news-input)))
(if (eof-object? next-line)
(close news-input)
(begin
(set! *data* (cons next-line *data*))
(loop (read-crlf-line news-input)))))))
(define (main req)
(if (null? *data*) (read-data))
(let loop ((count (- (length *data*) 1)))
(if (< count 0)
(send/finish
(make-response
http-status/ok
@ -36,7 +46,8 @@ That's it...</BODY></HTML>")))))
(format out
"<HTML><BODY><H1>~a<H1><P>
<A href=~a>read more...</A></BODY></HTML>"
next-line
(list-ref *data* count)
next-url))))))
(loop)))))))
(loop (- count 1))))))
))