update main to run the webserver (with sample weblets)

This commit is contained in:
Feufochmar 2019-11-07 12:14:41 +01:00
parent 81a8b3ab01
commit 9d3d4a38b3
1 changed files with 22 additions and 1 deletions

View File

@ -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*))