| 
									
										
										
										
											2022-05-07 17:54:23 +02:00
										 |  |  | #' Run the application server. | 
					
						
							|  |  |  | #' | 
					
						
							| 
									
										
										
										
											2022-05-12 13:37:53 +02:00
										 |  |  | #' @param host The hostname to serve the application on. | 
					
						
							| 
									
										
										
										
											2022-05-07 17:54:23 +02:00
										 |  |  | #' @param port The port to serve the application on. | 
					
						
							| 
									
										
										
										
											2022-12-02 15:16:37 +01:00
										 |  |  | #' @param custom_dataset This allows to set a custom dataset (return value of | 
					
						
							|  |  |  | #'   [analyze()]) as the default dataset of the UI. | 
					
						
							| 
									
										
										
										
											2025-03-05 17:03:07 +01:00
										 |  |  | #' @param show_api_docs Whether to show the API documentation. Use [run_api()] | 
					
						
							|  |  |  | #'   to actually serve the API. | 
					
						
							| 
									
										
										
										
											2022-05-07 17:54:23 +02:00
										 |  |  | #' | 
					
						
							| 
									
										
										
										
											2025-03-05 15:31:49 +01:00
										 |  |  | #' @seealso [app()] for retrieving a Shiny app object. | 
					
						
							|  |  |  | #' | 
					
						
							| 
									
										
										
										
											2022-05-07 17:54:23 +02:00
										 |  |  | #' @export | 
					
						
							| 
									
										
										
										
											2022-12-02 15:16:37 +01:00
										 |  |  | run_app <- function(host = "127.0.0.1", | 
					
						
							|  |  |  |                     port = 3464, | 
					
						
							| 
									
										
										
										
											2025-03-05 17:03:07 +01:00
										 |  |  |                     custom_dataset = NULL, | 
					
						
							|  |  |  |                     show_api_docs = FALSE) { | 
					
						
							| 
									
										
										
										
											2022-12-02 15:16:37 +01:00
										 |  |  |   runApp( | 
					
						
							| 
									
										
										
										
											2025-03-05 17:03:07 +01:00
										 |  |  |     app( | 
					
						
							|  |  |  |       custom_dataset = custom_dataset, | 
					
						
							|  |  |  |       show_api_docs = show_api_docs | 
					
						
							|  |  |  |     ), | 
					
						
							| 
									
										
										
										
											2022-12-02 15:16:37 +01:00
										 |  |  |     host = host, | 
					
						
							|  |  |  |     port = port | 
					
						
							|  |  |  |   ) | 
					
						
							| 
									
										
										
										
											2022-05-07 17:54:23 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-12-11 19:08:22 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-05 15:31:49 +01:00
										 |  |  | #' Create a shiny application for Ubigen. | 
					
						
							|  |  |  | #' | 
					
						
							|  |  |  | #' @param custom_dataset This allows to set a custom dataset (return value of | 
					
						
							|  |  |  | #'   [analyze()]) as the default dataset of the UI. | 
					
						
							| 
									
										
										
										
											2025-03-05 17:03:07 +01:00
										 |  |  | #' @param show_api_docs Whether to show the API documentation. Use [run_api()] | 
					
						
							|  |  |  | #'   to actually serve the API. | 
					
						
							| 
									
										
										
										
											2025-03-05 15:31:49 +01:00
										 |  |  | #' | 
					
						
							|  |  |  | #' @seealso [run_app()] for immediately running the application. | 
					
						
							|  |  |  | #' | 
					
						
							|  |  |  | #' @export | 
					
						
							| 
									
										
										
										
											2025-03-05 17:03:07 +01:00
										 |  |  | app <- function(custom_dataset = NULL, show_api_docs = FALSE) { | 
					
						
							| 
									
										
										
										
											2025-03-05 15:31:49 +01:00
										 |  |  |   shinyApp( | 
					
						
							| 
									
										
										
										
											2025-03-05 17:03:07 +01:00
										 |  |  |     ui( | 
					
						
							|  |  |  |       custom_dataset = custom_dataset, | 
					
						
							|  |  |  |       show_api_docs = show_api_docs | 
					
						
							|  |  |  |     ), | 
					
						
							|  |  |  |     server( | 
					
						
							|  |  |  |       custom_dataset = custom_dataset | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2025-03-05 15:31:49 +01:00
										 |  |  |   ) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-11 19:08:22 +01:00
										 |  |  | #' 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) | 
					
						
							|  |  |  | } |