first shot on adding servlets to HTTPD
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
(define-structure plugin plugin-interface
|
||||
(open scsh
|
||||
scheme
|
||||
plugin-utilities
|
||||
httpd-responses
|
||||
crlf-io)
|
||||
(begin
|
||||
(define (main req)
|
||||
(let ((news-input (open-input-file "news.txt")))
|
||||
(let loop ()
|
||||
(let ((next-line (read-crlf-line news-input)))
|
||||
(if (eof-object? next-line)
|
||||
(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
|
||||
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>"
|
||||
next-line
|
||||
next-url))))))
|
||||
(loop)))))))
|
||||
))
|
||||
@@ -0,0 +1,4 @@
|
||||
Bin Laden still alive!
|
||||
Mahadma Ghandi's grave stolen!
|
||||
MAKE MONEY FAST!
|
||||
Get mor bucks!!!
|
||||
@@ -0,0 +1,16 @@
|
||||
(define-structure plugin plugin-interface
|
||||
(open scsh
|
||||
scheme
|
||||
httpd-responses)
|
||||
(begin
|
||||
(define (main send/suspend)
|
||||
(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>THIS IS FROM SERVLET</H1></BODY></HTML>~%")))))))
|
||||
|
||||
Reference in New Issue
Block a user