Created
December 19, 2018 22:34
-
-
Save rgchris/fa7de8a11c7a903e3ab7116a90b51994 to your computer and use it in GitHub Desktop.
Small JSON server for Rebol 2
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
Rebol [ | |
Title: "JSON Server" | |
Date: 19-Dec-2018 | |
Author: "Christopher Ross-Gill" | |
] | |
do http://reb4.me/r/altjson | |
do http://reb4.me/r/httpd | |
data: [ ; in lieu of CSV data, from Rebol in Ten Steps | |
"Bill" billg@ms.com #315-555-1234 | |
"Steve" jobs@apl.com #408-555-4321 | |
"Ted" ted@gw2.com #213-555-1010 | |
] | |
my-server: open/custom httpd://:8888 [ | |
; default is to return 404 | |
switch probe request/action [ | |
"GET /" [ | |
response/status: 200 | |
response/content: "My Server (<a href='/quit'>Quit</quit>)" | |
response/type: "text/html" | |
] | |
"GET /data" [ | |
response/status: 200 | |
response/content: to-json data | |
response/type: "application/json" | |
] | |
"GET /quit" [ | |
response/status: 200 | |
response/content: "All Done." | |
response/kill?: yes | |
] | |
] | |
] | |
wait [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment