aboutsummaryrefslogtreecommitdiff
path: root/gn3-guile
diff options
context:
space:
mode:
Diffstat (limited to 'gn3-guile')
-rwxr-xr-xgn3-guile/web/webserver.scm35
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")