【发布时间】:2015-02-20 23:07:08
【问题描述】:
当 chrome 浏览器已经在我的桌面 (linux) 中打开时,我可以启动闪亮的应用程序。但是,当我关闭浏览器并启动闪亮的应用程序时,它只会在下方状态栏中显示一个空白页面和“等待 127.0.0.1 ...”。换句话说,它会启动 chrome,但不会显示闪亮的应用程序内容。这是我的代码:
library(shiny)
library(shinyBS)
launch.browser = function(appUrl, browser.path='/usr/bin/chromium-browser') {
system(sprintf('"%s" --disable-gpu --app="data:text/html,<html>
<head>
<title>Configuration</title>
</head>
<body>
<script>window.resizeTo(800,500);window.location=\'%s\';</script>
</body></html>"', browser.path, appUrl))
}
shinyApp(
ui = fluidPage(
fluidRow(
br(),
wellPanel(
fluidRow(
h4('User Information')
),
fluidRow(
column(4,
textInput('Name', 'Full Name', value = "")
),
column(4,
numericInput('accNum', 'Account Number', value = "")
),
column(4,
textInput('token', 'Account Token', value = "")
)
)
)
),
fluidRow(
column(12,
actionButton('save', 'Save')
)
),
bsTooltip(id = "accNum", title = "Enter Lending Club account number",
placement = "bottom", trigger = "hover")
# tags$head(tags$style(type="text/css", "#accNum {width: 100px}"))
),
server = function(input, output, session) {
session$onSessionEnded(function() {
stopApp()
})
observe({
if (input$save == 0)
return()
isolate({
j<<-input$accNum
})
})
},
options = list(launch.browser=launch.browser)
)
感谢您的帮助
* 编辑 1 *
我已验证浏览器可以正常启动并转到闪亮之外的指定 URL:
system('/usr/bin/chromium-browser --disable-gpu --app="data:text/html,<html>
<head>
<title>Configuration</title>
</head>
<body>
<script>window.resizeTo(800,500);window.location=\'http://www.facebook.com\';</script>
</body></html>"')
以上内容也适用于使用位置 facebook.com 的闪亮内部。但是,当我将其更改为 appUrl 参数时,它永远不会连接。我还验证了页面的源指向了正确的 127.0.0.1:3189,但是,看起来闪亮由于某种原因没有响应......
【问题讨论】:
-
如果从代码中启动 chrome 然后在该窗口中启动应用程序会怎样?我假设 127.0.0.1 是您的本地计算机还是运行闪亮应用程序的计算机?
-
感谢您的建议,但我宁愿不必做任何工作。 Shiny 应该能够根据我阅读的文档启动浏览器。但是,即使相同的启动命令在 Shiny 之外可以正常工作,也有一些原因导致它无法启动
标签: shiny shiny-server