Deploying my first shiny app - simple web scraper 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 an 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 on shinyapps
I've redacted the file name since it contained 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{
asdad <- parsingFunction(input$infile)
}
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)
parsingFunction
in the above code is a lengthy function that uses regular expressions and CSS headings (using rvest
) to get the desired info. It uses read_html
and html_nodes
from the rvest
package. All other operations are carried out using base R functionality.
Could this have something to do with the fact that I have a free account? The file that is being uploaded is only 418kb in size.
I've asked this question on StackOverflow without any answers. Posting the link here since I'm a new user and can not upload more than one image and two weblink: r - Error deploying shiny app that uses fileInput to upload data - Stack Overflow