Created
July 5, 2012 02:27
-
-
Save jadudm/3050679 to your computer and use it in GitHub Desktop.
Exploration of the PLT web server...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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") | |
|# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment