+(define (do-index req)
+ (http-response (include-template "index.html")))
+
+(define (search query)
+ (define engine (string->url
+ (string-append
+ "https://search.trom.tf/search?format=json&q=" query)))
+ (define response (get-pure-port engine))
+ (define json-raw (port->string response))
+ (close-input-port response)
+ (with-input-from-string json-raw (lambda () (read-json))))
+
+(define (http-response content) ; The 'content' parameter should be a string.
+ (response/full
+ 200 ; HTTP response code.
+ #"OK" ; HTTP response message.
+ (current-seconds) ; Timestamp.
+ TEXT/HTML-MIME-TYPE ; MIME type for content.
+ '() ; Additional HTTP headers.
+ (list ; Content (in bytes) to send to the browser.
+ (string->bytes/utf-8 content))))
+