Delay/avoid 闪亮的服务器端功能重复,直到凭据之后
Delay/avoid duplication of shiny server side functions until after credentials
我已经在 shinyapps.io 上安装了一个安全的应用程序,除了我的反应服务器功能开始 运行 外,一切都按预期运行,同时等待输入凭据,然后 运行 再次验证凭据。这似乎会导致应用程序使用额外的服务器时间和资源。有没有办法将服务器进程延迟到输入凭据之后。它的设置方式与 shinymanager 小插图中的示例相同:
library(shiny)
library(shinymanager)
credentials <- data.frame(user=c("USERNAME"),
password=c("PASSWORD"),
stringsAsFactors = FALSE)
ui <- fluidPage(
tags$h2("My secure application"),
)
# Wrap your UI with secure_app
ui <- secure_app(ui)
server <- function(input, output, session) {
# call the server part
# check_credentials returns a function to authenticate users
res_auth <- secure_server(
check_credentials = check_credentials(credentials)
)
output$auth_output <- renderPrint({
reactiveValuesToList(res_auth)
})
# all my server side functions here
}
shinyApp(ui, server)
认证成功后,我们可以使用observeEvent
、eventReactive
或bindEvent
触发服务器部分的功能:
library(shiny)
library(shinymanager)
credentials <- data.frame(
user = c("USERNAME"),
password = c("PASSWORD"),
stringsAsFactors = FALSE
)
ui <- fluidPage(
tags$h2("My secure application"),
verbatimTextOutput("auth_output"),
plotOutput("myPlot")
)
# Wrap your UI with secure_app
ui <- secure_app(ui)
server <- function(input, output, session) {
# call the server part
# check_credentials returns a function to authenticate users
res_auth <- secure_server(check_credentials = check_credentials(credentials))
output$auth_output <- renderPrint({
reactiveValuesToList(res_auth)
})
observeEvent(res_auth$user, {
# all my server side functions here
print("executing server functions...")
})
}
shinyApp(ui, server)
我已经在 shinyapps.io 上安装了一个安全的应用程序,除了我的反应服务器功能开始 运行 外,一切都按预期运行,同时等待输入凭据,然后 运行 再次验证凭据。这似乎会导致应用程序使用额外的服务器时间和资源。有没有办法将服务器进程延迟到输入凭据之后。它的设置方式与 shinymanager 小插图中的示例相同:
library(shiny)
library(shinymanager)
credentials <- data.frame(user=c("USERNAME"),
password=c("PASSWORD"),
stringsAsFactors = FALSE)
ui <- fluidPage(
tags$h2("My secure application"),
)
# Wrap your UI with secure_app
ui <- secure_app(ui)
server <- function(input, output, session) {
# call the server part
# check_credentials returns a function to authenticate users
res_auth <- secure_server(
check_credentials = check_credentials(credentials)
)
output$auth_output <- renderPrint({
reactiveValuesToList(res_auth)
})
# all my server side functions here
}
shinyApp(ui, server)
认证成功后,我们可以使用observeEvent
、eventReactive
或bindEvent
触发服务器部分的功能:
library(shiny)
library(shinymanager)
credentials <- data.frame(
user = c("USERNAME"),
password = c("PASSWORD"),
stringsAsFactors = FALSE
)
ui <- fluidPage(
tags$h2("My secure application"),
verbatimTextOutput("auth_output"),
plotOutput("myPlot")
)
# Wrap your UI with secure_app
ui <- secure_app(ui)
server <- function(input, output, session) {
# call the server part
# check_credentials returns a function to authenticate users
res_auth <- secure_server(check_credentials = check_credentials(credentials))
output$auth_output <- renderPrint({
reactiveValuesToList(res_auth)
})
observeEvent(res_auth$user, {
# all my server side functions here
print("executing server functions...")
})
}
shinyApp(ui, server)