Description Usage Arguments Details Examples
View source: R/jsonapi_server.R
Start a JSONAPI server
1 | jsonapi_server(port = 8000)
|
port |
(integer) the port to run the server on. default: 8000 |
Right now, this function doesn't take arbitrary input, but
instead serves the same content as this JSON API example
https://github.com/endpoints/endpoints-example. Note that not all
features are the same as the full endpoints-example
, but most
should work.
Right now, this function serves data from static, minified JSON files, so there's no dynamic database underneath.
Kill the server by CTRL+C, ESC or similar.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Not run:
# start server in another R session
if (interactive()) {
jsonapi_server()
# Back in this session ...
# Connect
(conn <- jsonapi_connect("http://localhost:8000"))
# Get data
conn$url
conn$version
conn$content_type
conn$routes()
conn$route("authors")
conn$route("chapters")
conn$route("authors/1")
conn$route("authors/1/books")
conn$route("chapters/5")
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.