update main to run the webserver (with sample weblets)
This commit is contained in:
parent
81a8b3ab01
commit
9d3d4a38b3
23
main.rkt
23
main.rkt
|
@ -6,5 +6,26 @@
|
|||
)
|
||||
|
||||
(module+ main
|
||||
(require
|
||||
"src/webcontainer/webcontainer.rkt")
|
||||
(require
|
||||
"src/webcontainer/weblets.rkt")
|
||||
;; Main entry point, executed when run with the `racket` executable or DrRacket.
|
||||
(displayln "Hello world!"))
|
||||
(define *webcontainer* (make-webcontainer))
|
||||
(webcontainer-add-weblet!
|
||||
*webcontainer*
|
||||
"/"
|
||||
(html-page-weblet
|
||||
#:body '(html (body (h1 "Hello World")))))
|
||||
(webcontainer-add-matching-weblet!
|
||||
*webcontainer*
|
||||
"/{name}"
|
||||
(html-page-weblet
|
||||
#:body (lambda (req params)
|
||||
`(html (body (h1 "Hello " ,(hash-ref params 'name)))))))
|
||||
(webcontainer-set-404-weblet!
|
||||
*webcontainer*
|
||||
(html-page-weblet
|
||||
#:body '(html (body (h1 "Sorry") (p "Nothing found here")))))
|
||||
(display "Starting server...")(newline)
|
||||
(webcontainer-start *webcontainer*))
|
||||
|
|
Loading…
Reference in New Issue