Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rgchris
Last active February 11, 2017 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgchris/c3fa52d8a68c8021c1b0c53a720bae44 to your computer and use it in GitHub Desktop.
Save rgchris/c3fa52d8a68c8021c1b0c53a720bae44 to your computer and use it in GitHub Desktop.
Get Object
#!/usr/local/bin/rebol -cs
Rebol [
Title: "Get Object"
Author: "Christopher Ross-Gill"
]
do %httpd.r
do %altjson.r
bulbs: [
[one][two][three][four]
]
open/custom httpd://:8080 [
path: parse/all next any [request/target "/"] "/"
response/type: "application/json"
response/content: to-json switch/default take path [
"lights" [
switch/default take path [
"3" [bulbs/3]
"4" [bulbs/4]
#[none] [bulbs]
][
["Not Found"]
]
]
][
["Not Found"]
]
]
browse http://127.0.0.1:8080/lights/4
wait []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment