aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPjotr Prins2023-07-10 10:58:02 -0500
committerPjotr Prins2023-07-10 10:58:02 -0500
commit188c3d7880fd6481af4758b3e94577e81031c3c5 (patch)
tree52d0a8d07ef6180bbbc113c7b6ddb72380a64b8b
parent8ddd7f80f15943f9a48ac760babff9da9f95c043 (diff)
downloadgenenetwork3-188c3d7880fd6481af4758b3e94577e81031c3c5.tar.gz
Execute SPARQL and get s-exp
-rw-r--r--gn3-guile/web/.guix-shell4
-rwxr-xr-xgn3-guile/web/webserver.scm9
2 files changed, 9 insertions, 4 deletions
diff --git a/gn3-guile/web/.guix-shell b/gn3-guile/web/.guix-shell
index bb14b26..2be81ce 100644
--- a/gn3-guile/web/.guix-shell
+++ b/gn3-guile/web/.guix-shell
@@ -1,8 +1,8 @@
#!/bin/bash
#
# run with options '-- ./webserver.scm 8091' e.g.
-# . .guix-shell -- guile -e main ./webserver.scm 8091
+# . .guix-shell -- guile --listen=1970 -e main ./webserver.scm 8091
echo "Note run: running web-server"
-guix shell guile guile-fibers guile-json gnutls guile-readline guile-redis openssl nss-certs $*
+guix shell guile guile-fibers guile-json guile-gnutls guile-readline guile-redis openssl nss-certs $*
diff --git a/gn3-guile/web/webserver.scm b/gn3-guile/web/webserver.scm
index 7ce2a9a..e72eba9 100755
--- a/gn3-guile/web/webserver.scm
+++ b/gn3-guile/web/webserver.scm
@@ -10,6 +10,8 @@
(json)
(ice-9 match)
(ice-9 format)
+ (ice-9 iconv)
+ (ice-9 receive)
(srfi srfi-1)
(srfi srfi-26)
(web http)
@@ -91,8 +93,11 @@ CONSTRUCT {
;; curl "https://sparql.genenetwork.org/sparql?default-graph-uri=&query=prefix+gn%3A+%3Chttp%3A%2F%2Fgenenetwork.org%2F%3E+%0D%0A%0D%0ASELECT+distinct+*+WHERE+%7B%3Fu++gn%3AbinomialName+%3Fo%7D&format=application%2Fsparql-results%2Bjson"|jq
(define (get-species)
- (http-get "http://sparql.genenetwork.org/sparql?default-graph-uri=&query=")
- )
+ (bytevector->string (receive (response-status response-body)
+ (http-request "https://sparql.genenetwork.org/sparql?default-graph-uri=&query=prefix+gn%3A+%3Chttp%3A%2F%2Fgenenetwork.org%2F%3E+%0D%0A%0D%0ASELECT+distinct+*+WHERE+%7B%3Fu++gn%3AbinomialName+%3Fo%7D&format=application%2Fsparql-results%2Bjson")
+
+ response-body) "UTF-8"
+ ))
(define (get-species-api-str)
(scm->json-string #("https://genenetwork.org/api/v2/mouse/"