public
Created

Exploration of the PLT web server...

  • Download Gist
explore.rkt
Racket
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
#lang racket
(require web-server/dispatch
web-server/http
web-server/dispatchers/dispatch
)
 
(define-values (dispatch blog-url)
(dispatch-rules
[("") serve-static]
[("go" (string-arg)) go]
[else (next-dispatcher)]
))
 
(define (serve-static req)
;; Actually, I'd like to serve static content here.
;; Perhaps from a directory that has the path ./htdocs/
;; relative to the server launch point.
(response/xexpr
`(div (p "serve") )))
 
(define (go req json)
;; If they hit /go, then I'd like to do something.
(response/xexpr
`(div (p "go")
(p ,json))))
 
;; Some magic happens down here that might let
;; me make the above happen
(serve/dispatch dispatch)
;; I was playing with things down here, and this wasn't getting
;; me anywhere in particular.
 
#|
(serve/servlet start
#:launch-browser? #t
#:extra-files-paths
(list (build-path (current-directory) "htdocs"))
#:servlet-path "/"
#:log-file
"its.log")
|#

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.