Skip to content

Commit

Permalink
hdplisp-on-racket (#18): testing how to access webservices in JSON us…
Browse files Browse the repository at this point in the history
…ing Racket
  • Loading branch information
fititnt committed Apr 15, 2021
1 parent 0b3bf54 commit 16db914
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
19 changes: 19 additions & 0 deletions hdpl-conventions/proof-of-concept/racket-lang/un-cod-services.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#lang racket

;; TODO: make this example with Racket
;; https://simonbjohnson.github.io/COD_demos/mongolia/




(require hdpl/systema/un/un-cod-services)

; (require hdpl/un/un-cod-services)

; (require (lib "hdpl/un/un-cod-services"))


; (require (lib "hdpl/un/un-cod-services"))


(extract "the aaaacat out of the bag")
3 changes: 3 additions & 0 deletions hdpl-conventions/prototype/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ raco pkg new hdpl
## Install/Reinstall from local path
raco pkg install --link ./hdpl/


raco pkg update --link ./hdpl/

## See docs
raco docs hdpl

Expand Down
1 change: 1 addition & 0 deletions hdpl-conventions/prototype/hdpl/systema/un-cod-services
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#lang racket
31 changes: 31 additions & 0 deletions hdpl-conventions/prototype/hdpl/systema/un/un-cod-services.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#lang racket
;; File: /hdpl/systema/un/un-cod-services.rkt
;; Author: 2021, Emerson Rocha (Etica.AI) <[email protected]>
;; License: Public Domain / BSD Zero Clause License
;; SPDX-License-Identifier: Unlicense OR 0BSD


(provide extract)

(module nest racket
(provide num-eggs)
(define num-eggs 2))


(define (extract str)
(substring str 4 7))

;(extract "the cat out of the bag")

;; Example from https://medium.com/chris-opperwall/practical-racket-using-a-json-rest-api-3d85eb11cc2d
(define IPHONE_7_TEARDOWN "https://www.ifixit.com/api/2.0/guides/67382")
(require net/url)
(require json)
(define (get-json url)
(call/input-url (string->url url)
get-pure-port
(compose string->jsexpr port->string)))
(define guide-data (get-json IPHONE_7_TEARDOWN))
(map (lambda (tool)
(hash-ref tool 'text))
(hash-ref guide-data 'tools))

0 comments on commit 16db914

Please sign in to comment.