123456789101112131415161718192021222324252627282930313233 |
- (use-modules (web server))
- (use-modules (web request)
- (web response)
- (web uri)
- (sxml simple))
- (define (request-path-components request)
- (split-and-decode-uri-path (uri-path (request-uri request))))
- (define (not-found request)
- (values (build-response #:code 404)
- (string-append "Resource not found: "
- (uri->string (request-uri request)))))
- (define (templatize title body)
- `(html (head (title ,title))
- (body ,@body)))
- (define (hello-hacker-handler request body)
- (if (equal? (request-path-components request)
- '("hacker"))
- (values
- (build-response #:headers '((content-type text/html)))
- (lambda (port)
- (let ([port 8080])
- (if sxml
- (begin
- (if doctype (display doctype port))
- (sxml->xml sxml port))))))
- (not-found request)))
- (run-server hello-hacker-handler)
|