diff options
author | Pjotr Prins | 2023-07-22 11:41:24 +0200 |
---|---|---|
committer | Pjotr Prins | 2023-07-22 11:41:24 +0200 |
commit | 9cd3e8a4729920794cd8c14be6f7bf280910378c (patch) | |
tree | fdb5eb6ae664fdc9f477f10b304b74d5d275c309 /gn3-guile/web/webserver.scm | |
parent | 3349ce0a5817e7c3cbc9caf5db8b0ca45d984214 (diff) | |
download | genenetwork3-9cd3e8a4729920794cd8c14be6f7bf280910378c.tar.gz |
This works
Diffstat (limited to 'gn3-guile/web/webserver.scm')
-rwxr-xr-x | gn3-guile/web/webserver.scm | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/gn3-guile/web/webserver.scm b/gn3-guile/web/webserver.scm index 6451dc5..db9eb62 100755 --- a/gn3-guile/web/webserver.scm +++ b/gn3-guile/web/webserver.scm @@ -139,16 +139,30 @@ SELECT ?species ?p ?o WHERE { (let* ([s (car r)] [v (cdr (cdr r))] [p (car (cdr r))] - [nrec (sloppy-assoc s recs)]) ; find record to fill based on subject - (if (nrec) - (begin - (set! nrec (assoc-set! nrec p v)) - (set! recs (assoc-set! recs s nrec))) - (set! nrec (assoc-set! nrec s '())) ;; start with empty list - ))) + [nrec '()] + [kv (assoc s recs)]) ; find record to fill based on subject + (if (not kv) + (set! nrec '()) + (set! nrec (cdr kv)) + ) + (set! nrec (assoc-set! nrec p v)) + (set! recs (assoc-set! recs s nrec)) + )) rows) recs) +;; result should be a vector of list of pair +(define (tojson recs) + (for-each (lambda (r) + (let ([k (car r)] + [v (cdr r)]) + (display k) + (newline) + (display r) + (newline) + )) recs + )) + (define (get-species-api-str) (scm->json-string #("https://genenetwork.org/api/v2/mouse/" "https://genenetwork.org/api/v2/rat/"))) @@ -169,10 +183,17 @@ SELECT ?species ?p ?o WHERE { (lambda (port) (scm->json json port)))) +(define (render-json-string2 json) + (list '((content-type . (application/json))) + (lambda (port) + (display "ThthEST" port)))) + (define (controller request body) (match-lambda (('GET) (render-json info)) + (('GET "meh") + (render-json-string2 "ITEST")) (('GET "meta") (render-json info-meta)) (('GET "version") |