mirror of
https://github.com/johrpan/ubigen.git
synced 2025-10-26 19:57:24 +01:00
Add API using plumber
This commit is contained in:
parent
26a209aade
commit
7f70a0c90b
5 changed files with 168 additions and 0 deletions
20
R/app.R
20
R/app.R
|
|
@ -18,3 +18,23 @@ run_app <- function(host = "127.0.0.1",
|
|||
port = port
|
||||
)
|
||||
}
|
||||
|
||||
#' Run the Ubigen API.
|
||||
#'
|
||||
#' This requires the `plumber` package to be installed.
|
||||
#'
|
||||
#' @param host The hostname to serve the API on.
|
||||
#' @param port The port to serve the API on.
|
||||
#'
|
||||
#' @export
|
||||
run_api <- function(host = "127.0.0.1", port = 3465) {
|
||||
if (!requireNamespace("plumber", quietly = TRUE)) {
|
||||
stop("Please install \"plumber\" to use this function.")
|
||||
}
|
||||
|
||||
plumber::plumb(file = system.file(
|
||||
"plumber", "ubigen", "plumber.R",
|
||||
package = "ubigen"
|
||||
)) |>
|
||||
plumber::pr_run(host = host, port = port, docs = FALSE)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue