| api_run | R Documentation |
This function starts the api with the settings it has defined.
api_run(
api,
host = NULL,
port = NULL,
block = !is_interactive(),
showcase = is_interactive(),
...,
silent = FALSE
)
api_stop(api)
api |
A plumber2 api object to launch or stop |
host, port |
Host and port to run the api on. If not provided the host and port used during the creation of the Plumber2 api will be used |
block |
Should the console be blocked while running (alternative is
to run in the background). Defaults to |
showcase |
Should the default browser open up at the server address.
If |
... |
Arguments passed on to the |
silent |
Should startup messaging by silenced |
These functions return the api object allowing for easy chaining
with the pipe, even though they will often be the last part of the chain
pa <- api() |>
api_get("/", function() {
list(msg = "Hello World")
}) |>
api_on("start", function(...) {
cat("I'm alive")
})
# Start the server
pa |> api_run(block = FALSE)
# Stop it again
pa |> api_stop()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.