Deploying ShinyApp to Shinyapps.io causes error

Hello,
I'm trying to deploy a very simple R-shiny app to shinyapps.io. I keep getting the following error:

Error in value[[3L]](cond) : app.R did not return a shiny.appobj object. Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous> Execution halted

This is my code:


library(shiny)
library(shinyWidgets)

# USER INTERFACE ------------------------------------
# Define UI for application that generates a list of random numbers
ui <- fluidPage(
  setBackgroundColor(
    color = "ghostwhite",
    
    
    gradient = c("linear", "radial"),
    direction = c("bottom", "top", "right", "left"),
    shinydashboard = FALSE
  ),
  
  # Application title
  titlePanel('Spontaneous speeches prompt generator!'),
  
  # Sidebar with inputs for the randome number generator
  sidebarLayout(
    sidebarPanel(
      actionButton("do", "Give me a prompt!")
    ),
    
    # Show a table of random numbers using the Server's output called "randNumbers"
    mainPanel(
      textOutput('text1'),
      tags$head(tags$style("#text1{color: red;
                           font-size: 20px;
                           font-style: italic;
                           }"
                         )
      )
      )
      )
      )


# SERVER INFORMATION --------------------------------
# Define server logic required to display table of random numbers
server <- function(input, output) {
  
  # Use an action button as an event to generate the list of random numbers
  random_data <- eventReactive(input$do, {  
    
    # Randomly sample values from the specified range
    prompts <- c('prompt1','prompt2')
    sample(prompts,1)
    
  })
  
  # Output the list of random numbers only AFTER the "Generate!" button is pressed
  output$text1 <- renderText({
    random_data()
  })
}

Thank you for your help!

You need this at the bottom


    shinyApp(ui, server)

Hey, I added the line but it didn't change anything sadly..

Code now looks like this:


library(shiny)
library(shinyWidgets)

# USER INTERFACE ------------------------------------
# Define UI for application that generates a list of random numbers
ui <- fluidPage(
  setBackgroundColor(
    color = "ghostwhite",
    
    
    gradient = c("linear", "radial"),
    direction = c("bottom", "top", "right", "left"),
    shinydashboard = FALSE
  ),
  
  # Application title
  titlePanel('Spontaneous speeches prompt generator!'),
  
  # Sidebar with inputs for the randome number generator
  sidebarLayout(
    sidebarPanel(
      actionButton("do", "Give me a prompt!")
    ),
    
    # Show a table of random numbers using the Server's output called "randNumbers"
    mainPanel(
      textOutput('text1'),
      tags$head(tags$style("#text1{color: red;
                           font-size: 20px;
                           font-style: italic;
                           }"
                         )
      )
      )
      )
      )


# SERVER INFORMATION --------------------------------
# Define server logic required to display table of random numbers
server <- function(input, output) {
  
  # Use an action button as an event to generate the list of random numbers
  random_data <- eventReactive(input$do, {  
    
    # Randomly sample values from the specified range
    prompts <- c('prompt1','prompt2')
    sample(prompts,1)
    
  })
  
  # Output the list of random numbers only AFTER the "Generate!" button is pressed
  output$text1 <- renderText({
    random_data()
  })
}


shinyApp(ui, server)

Is this script called app.R?

Yes it is! So that is probably not the issue..

I deployed the script succesfully to shinyapps.io,
are you sure you reported the full error correctly?
perhaps restarting your R session is a good idea, to ensure it didnt get into a bad state.