X-Git-Url: https://git.armaanb.net/?p=bettersearch.git;a=blobdiff_plain;f=server.rkt;h=42da28635db7c462026ea9d7e36b0516f858f056;hp=81abf7cb1b0cbdd5fe3edf0bcf9260dea6f7b530;hb=a9a5b5052fd87d1d7fd66ff68764ab87a2379a80;hpb=a0536c3fe9b8690ba944a4947df2bf6f8d7eefa7 diff --git a/server.rkt b/server.rkt index 81abf7c..42da286 100644 --- a/server.rkt +++ b/server.rkt @@ -14,12 +14,21 @@ (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 @@ -36,7 +45,7 @@ #"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)))) @@ -68,8 +77,11 @@ 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