# HTML Response
start.server("localhost", 8000, function(request) {
html.response("Hello World")
})
# Use jsonlite to create json responses
json.response <- function(body, headers = NULL) {
create.response(
200,
headers = c(
list("Content-Type" = "application/json"),
headers
),
body = jsonlite::toJSON(body, auto_unbox = TRUE)
)
}
start.server("localhost", 8000, function(request) {
json.response(request)
})