Deploying my first shiny app -- simple html parser that lets users upload an html file and then parses it to get info on shares/mentions/likes on LinkedIn.
The app runs fine locally (tested before deployment) and Rstudio does not show any errors with deployment. However, when I run it using the shinyapps link it appears the upload fails to complete and I don't get any output.
What it looks like locally
Opening App
Uploading an .html file
What it looks like on shinyapps.io
I've redacted the file name since it contains identifying information.
The code is as below:
library(rvest)
library(shiny)
ui <- fluidPage(
# theme = "https://bootswatch.com/4/superhero/bootstrap.css",
title = "LinkedIn Report",
fluidRow(
column(12,
fileInput("infile", "Choose .html file",
accept = "text/html", multiple = F) )
),
fluidRow(
column(12,
tableOutput("savedLocation") )
),
fluidRow(
column(12,
tableOutput("parsedData") ),
column(8,
downloadButton("downloadData", "Download"))
)
)
server <- function(input, output){
dd <- reactive(input$infile)
output$savedLocation <- renderTable({
if(is.null(input$infile)){
return(data.frame(Elapsed = character(),
Time = character(),
Name = character(),
Action = character()))
}else{
return(dd())
}
})
actual_data <- reactive({
if(is.null(input$infile)){
asdad <- data.frame(Elapsed = character(),
Time = character(),
Name = character(),
Action = character())
}else{
notifications <- read_html(input$infile$datapath)
name_action <- gsub("\\n", "", notifications %>% html_nodes(".nt-card__text--3-line") %>% html_text())
tme <- trimws(gsub("\\n", "", notifications %>% html_nodes(".nt-card__time-ago") %>% html_text()))
action <- notifications %>% html_nodes(".nt-card__text--3-line strong") %>% html_text
nme <- trimws( sapply(1:length(name_action), function(z) gsub(action[z], "", name_action[z])))
asdad <- data.frame(Elapsed = tme, Time = elap(tme), Name = nme, Action = action)
}
return(asdad)
})
output$parsedData <- renderTable({ actual_data()})
output$downloadData <- downloadHandler(
filename = "yourdata.csv",
content = function(filename){ write.table(actual_data(), file = filename,
row.names = F, sep = ",")}
)
}
shinyApp(ui = ui, server = server)
Could this have something to do with the fact that I have a free account? The file that is being uploaded is less than 420kb in size.
I've looked at the following questions but they don't address the above:
- Shiny app deployment error on shinyapps.io
- Error in deploying a shiny app
- Unable to deploy shiny app on shiny server
Rstudio has a similar example using fileInput
that can be found here: https://shiny.rstudio.com/articles/upload.html