部署闪亮的应用程序时如何解决黑屏问题?

时间:2020-06-08 01:46:29

标签: r deployment shiny

根据以下文章,我正在尝试部署一个闪亮的应用程序:https://www.r-bloggers.com/deploying-desktop-apps-with-r/

运行程序时,Chrome启动,但什么也没有,只有空白屏幕。

这是我的闪亮应用程序,名为runShinyApp.R:

library(shiny)
message('library paths:\n', paste('... ', .libPaths(), sep='', collapse='\n'))

chrome.portable = file.path(getwd(),
                            'GoogleChromePortable/App/Chrome-bin/chrome.exe')

launch.browser = function(appUrl, browser.path=chrome.portable) {
  message('Browser path: ', browser.path)
  shell(sprintf('"%s" --app=%s', browser.path, appUrl))
}

shiny::runApp('./shiny/', launch.browser=launch.browser)

我的服务器文件:

library(shiny)
server <- function(input, output, session) {
  # MODIFY CODE BELOW: Wrap in observeEvent() so the help text 
  # is displayed when a user clicks on the Help button.
  observeEvent(input$show_help, {
    # Display a modal dialog with bmi_help_text
    # MODIFY CODE BELOW: Uncomment code
    showModal(modalDialog(bmi_help_text))
  })
  rv_bmi <- eventReactive(input$show_bmi, {
    input$weight/(input$height^2)
  })
  output$bmi <- renderText({
    bmi <- rv_bmi()
    paste("Hi", input$name, ". Your BMI is", round(bmi, 1))
  })
}


我的ui文件:

library(shiny)
bmi_help_text <- ""
ui <- fluidPage(
  titlePanel('BMI Calculator'),
  sidebarLayout(
    sidebarPanel(
      textInput('name', 'Enter your name'),
      numericInput('height', 'Enter your height in meters', 1.5, 1, 2),
      numericInput('weight', 'Enter your weight in Kilograms', 60, 45, 120),
      actionButton("show_bmi", "Show BMI"),
      # CODE BELOW: Add an action button named "show_help"
      actionButton("show_help", "Help")
    ),
    mainPanel(
      textOutput("bmi")
    )
  )
)

错误屏幕: The error screen

0 个答案:

没有答案
相关问题