71 lines
1.7 KiB
Scheme
71 lines
1.7 KiB
Scheme
(define-structure surflet surflet-interface
|
|
(open scheme-with-scsh
|
|
surflets
|
|
httpd-responses)
|
|
(begin
|
|
(define global '())
|
|
|
|
(define select (make-select-input-field '("a" "b" "c") #t '(@ (size 2))))
|
|
|
|
(define (main req)
|
|
(set! global (cons 1 global))
|
|
(let* ((addr (make-annotated-address))
|
|
(req (send-html/suspend
|
|
(lambda (new-url)
|
|
`(html (body (h1 "This is from SUrflet")
|
|
(p "called " ,(length global) " times")
|
|
(url ,(addr new-url "ab=ba")) (br)
|
|
(url ,(addr new-url "be<ta")) (br)
|
|
(url ,(addr new-url)) (br)
|
|
(abba)
|
|
(surflet-form
|
|
,new-url
|
|
POST
|
|
,select
|
|
'(input (@ (type "text") (name "TeST")))
|
|
,(make-submit-button))
|
|
(hr)
|
|
(p (url "/" "Return to main menu."))
|
|
)))))
|
|
(save-k #f)
|
|
(done? #f)
|
|
(bindings (get-bindings req))
|
|
(result
|
|
(cond
|
|
((returned-via? addr bindings) =>
|
|
(lambda (string)
|
|
(format #f "returned via annotated string ~s" string)))
|
|
(else
|
|
(format #f "~s" bindings)))))
|
|
|
|
(call-with-current-continuation
|
|
(lambda (k)
|
|
(set! save-k k)
|
|
13))
|
|
|
|
(set! global (cons 1 global))
|
|
(if (not done?)
|
|
(begin
|
|
(send-html/suspend
|
|
(lambda (continue)
|
|
`(html (body (h1 "Result")
|
|
(p "called " ,(length global) " times")
|
|
,result (br)
|
|
(url ,continue "show results again")
|
|
(hr)
|
|
(p (url "test.scm" "Test again.") (br)
|
|
(url "/" "Return to main menu."))))))
|
|
|
|
(set! done? #t)
|
|
(save-k 13))
|
|
|
|
(send-html/finish
|
|
`(html (body (h1 "Result 2")
|
|
(p "called " ,(length global) " times")
|
|
,(format #f "~s" (get-bindings req))
|
|
(hr)
|
|
(p (url "test.scm" "Test again.") (br)
|
|
(url "/" "Return to main menu."))))))))
|
|
|
|
))
|