racket/collects/little-helper/web-root/htdocs/Defaults/documentation/examples/add.ss
Jens Axel Soegaard ac47e02961 Initial checkin of Little Helper.
Little Helper contains a full text search engine. 
Currently it indexes all html-files in /collects/doc.
A mockup web-interface is present in order to facilitate easy experimentation with searches.
Run run-indexer to generate the index for your documentation dir. 
Run launch to start a web-server with the search interface.
Note: Currently assumes w3m is in your path (used to precompute the 
           preview-snippets shown in the search results.

svn: r8836
2008-03-01 13:26:18 +00:00

29 lines
1.1 KiB
Scheme

(require (lib "unitsig.ss")
(lib "servlet-sig.ss" "web-server")
(lib "date.ss"))
(unit/sig () (import servlet^)
; request-number : str -> num
(define (request-number which-number)
(string->number
(extract-binding/single
'number
(request-bindings (send/suspend (build-request-page which-number))))))
; build-request-page : str -> str -> response
(define (build-request-page which-number)
(lambda (k-url)
`(html (head (title "Enter a Number to Add"))
(body ([bgcolor "white"])
(form ([action ,k-url] [method "post"])
"Enter the " ,which-number " number to add: "
(input ([type "text"] [name "number"] [value ""]))
(input ([type "submit"] [name "enter"] [value "Enter"])))))))
(send/suspend
(lambda (k-url)
`(html (head (title "Sum"))
(body ([bgcolor "white"])
(p "The sum is "
,(number->string (+ (request-number "first") (request-number "second")))))))))