shiny app works locally but not on server

I have browsed here some similar posts and realized that this error may result from vary reasons. So I still post my problem here. I am sorry that I am not able to provide a reproducible example, because I need to use some other local files (thousands of png files) in the code.

So here is the code:

library(shiny)

ui=fluidPage(
  titlePanel('hello shiny'),
  sidebarPanel(
    textInput('ID',label='ID:'),actionButton('goButton',label='submit')
    ),
  mainPanel(imageOutput('out'))
)

server <- function(input, output,session) {
  fullnames=list.files(path = "/Users/u/Documents/myapp/www", pattern = ".png");
  reactive({
            input$ID=gsub(pattern = '\\.png','',fullnames)
            }
           );
  output$out=renderImage(
    {
     filenames=normalizePath(file.path('/Users/u/Documents/myapp/www',paste(input$ID,'.png',sep='')));
     list(src=filenames)
    },
    deleteFile = F
     
  )
}

shinyApp(ui,server)

the error:

Listening on http://127.0.0.1:7453
Warning in normalizePath(file.path("/Users/u/Documents/myapp/www",  :
  path[1]="/Users/u/Documents/myapp/www/.png": No such file or directory

I am guessing something is wrong with the input, as the warning shows incomplete path. It still works locally, but not on server, with the same warning (error) on the server log. Any idea how to fix it? Thank you very much.

This path doesn't exist in the server, you have to use a relative path (relative to the application's root directory) instead of an absolute one.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.