inst/examples/rserve/app.R

#!/usr/bin/env Rscript

## ---- HTTTP request handler ----

.http.request = function(path, query, body, headers) {
  if (path == "/hello") {
    resp_body = "Hello, World!"
    status_code = 200L
  } else {
    resp_body = "Not Found"
    status_code = 404L
  }

  resp_headers = character(0)
  content_type = "text/plain"
  list(
    resp_body,
    content_type,
    resp_headers,
    status_code
  )
}


## ---- start application ----

# Rserve::run.Rserve(http.port = 8080)

Try the RestRserve package in your browser

Any scripts or data that you put into this service are public.

RestRserve documentation built on May 29, 2024, 8:18 a.m.