-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hdplisp-on-racket (#18): testing how to access webservices in JSON us…
…ing Racket
- Loading branch information
Showing
4 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
hdpl-conventions/proof-of-concept/racket-lang/un-cod-services.rkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#lang racket |
31 changes: 31 additions & 0 deletions
31
hdpl-conventions/prototype/hdpl/systema/un/un-cod-services.rkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |