remove external state error
This commit is contained in:
parent
84a92fb2b5
commit
93b2ab23b1
|
@ -5,12 +5,36 @@
|
||||||
httpd-responses
|
httpd-responses
|
||||||
crlf-io)
|
crlf-io)
|
||||||
(begin
|
(begin
|
||||||
(define (main req)
|
(define *data* '())
|
||||||
|
|
||||||
|
(define (read-data)
|
||||||
(let ((news-input (open-input-file "news.txt")))
|
(let ((news-input (open-input-file "news.txt")))
|
||||||
(let loop ()
|
(let loop ((next-line (read-crlf-line news-input)))
|
||||||
(let ((next-line (read-crlf-line news-input)))
|
(if (eof-object? next-line)
|
||||||
(if (eof-object? next-line)
|
(close news-input)
|
||||||
(send/finish
|
(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
|
||||||
|
(status-code->text http-status/ok)
|
||||||
|
(time)
|
||||||
|
"text/html"
|
||||||
|
'()
|
||||||
|
(make-writer-body
|
||||||
|
(lambda (out options)
|
||||||
|
(format out
|
||||||
|
"<HTML><BODY><H1>THAT'S IT<H1><P>
|
||||||
|
That's it...</BODY></HTML>")))))
|
||||||
|
(begin
|
||||||
|
(send/suspend
|
||||||
|
(lambda (next-url)
|
||||||
(make-response
|
(make-response
|
||||||
http-status/ok
|
http-status/ok
|
||||||
(status-code->text http-status/ok)
|
(status-code->text http-status/ok)
|
||||||
|
@ -20,23 +44,10 @@
|
||||||
(make-writer-body
|
(make-writer-body
|
||||||
(lambda (out options)
|
(lambda (out options)
|
||||||
(format out
|
(format out
|
||||||
"<HTML><BODY><H1>THAT'S IT<H1><P>
|
"<HTML><BODY><H1>~a<H1><P>
|
||||||
That's it...</BODY></HTML>")))))
|
|
||||||
(begin
|
|
||||||
(send/suspend
|
|
||||||
(lambda (next-url)
|
|
||||||
(make-response
|
|
||||||
http-status/ok
|
|
||||||
(status-code->text http-status/ok)
|
|
||||||
(time)
|
|
||||||
"text/html"
|
|
||||||
'()
|
|
||||||
(make-writer-body
|
|
||||||
(lambda (out options)
|
|
||||||
(format out
|
|
||||||
"<HTML><BODY><H1>~a<H1><P>
|
|
||||||
<A href=~a>read more...</A></BODY></HTML>"
|
<A href=~a>read more...</A></BODY></HTML>"
|
||||||
next-line
|
(list-ref *data* count)
|
||||||
next-url))))))
|
next-url))))))
|
||||||
(loop)))))))
|
(loop (- count 1))))))
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue