feuforeve.v4/main.rkt

32 lines
884 B
Racket
Raw Normal View History

#lang racket/base
(module+ test
(require rackunit)
;; Tests to be run with raco test
)
(module+ main
(require
"src/webcontainer/webcontainer.rkt")
(require
"src/webcontainer/weblets.rkt")
;; Main entry point, executed when run with the `racket` executable or DrRacket.
(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*))