(define-values (dispatch generate-url)
(dispatch-rules
- [("index") do-index]
+ [("") do-index]
[("search") do-search]
))
+(define (do-head title)
+ (include-template "templates/head.html"))
+
+(define (do-footer)
+ (include-template "templates/footer.html"))
+
(define (do-index req)
- (http-response (include-template "index.html")))
+ (http-response (string-append
+ (do-head "Web Search")
+ (include-template "templates/index.html")
+ (do-footer))))
(define (search query)
(define engine (string->url
#"OK" ; HTTP response message.
(current-seconds) ; Timestamp.
TEXT/HTML-MIME-TYPE ; MIME type for content.
- '() ; Additional HTTP headers.
+ '() ; Additional HTTP heads.
(list ; Content (in bytes) to send to the browser.
(string->bytes/utf-8 content))))
ht
))
(hash-ref (search query) 'results)))))
- (http-response (include-template "search.html")))
- (do-index req)))
+ (http-response (string-append
+ (do-head (string-append query " | Web Search"))
+ (include-template "templates/search.html")
+ (do-footer))))
+ (redirect-to "/")))
(serve/servlet dispatch
#:command-line? #t