I wrote my first R Shiny app for a work project and am now attempting to deploy it to shinyapps.io. It works fine on its own when launched from RStudio and works fine when downloaded from my GitHub repository. You can download the repository here: https://github.com/UK-PHEG/PH1_Shiny_web_app/
The problem is that when I attempt to publish the app to shinyapps.io, I get the error:
✔ Deploying "PH1_shiny_app" using "server: shinyapps.io / username: uk-pheg"
Error in `inferAppPrimaryDoc()`:
! Failed to determine `appPrimaryDoc`.
✖ No files matching "\\.html?$".
So it looks like I need an HTML file. I did some research and found that I am supposed to specify my shinyApp() function as:
shinyApp(ui, server, options = list(primaryDoc = shiny::htmlTemplate("index.html")))
However, when I attempt this I get this error:
Warning in file(con, "rb") :
cannot open file 'index.html': No such file or directory
Error in file(con, "rb") : cannot open the connection
I cannot find any info online for what this html file needs to be, how to create it and where it needs to be placed in the directory structure. Any help you can provide would be greatly appreciated! Thanks!
The error implies that the deployApp()
function has failed to find the primary document of your Shiny application, e.g. an app.R
file, or corresponding ui.R
and server.R
files.
Chances are you are simply providing the root directory of your project files, but not the root directory of the Shiny project itself. The path you should specify is the directory that contains the app.R
file.
e.g. with the following directory structure
.
└── your-project/
└── R/
└── app.R
you should call deployApp('your-project/R/')
.