library(shiny)
library(shiny.router)
library(shinydashboard)
library(shinyWidgets)
library(png)
library(flexdashboard)
library(jsonlite)
library(reticulate)
library(httr)
Location <- c('East','West','South','North','NorthEast','SouthEast','SouthWest','NorthWest')
industry <- c('Finance','Media','Healthcare','Retail','Telecommunications','Automotive','Digital Marketing', 'Professional Services','Cyber Security', 'Mining','Government','Manufacturing','Transport')
skills <- c('Python','R programming', 'Java', 'SQL', 'C++', 'C', 'Interpersonal skills', 'Machine Learning', 'Deep Learning', 'Data Visualisation', 'Data wrangling')
jobtype <- c('Full time', 'Full time', 'Internship')
home_page <- div(
ui <- dashboardPage(
dashboardHeader(title = "Job Portal"),
dashboardSidebar(
sidebarMenu(
menuItem("Search", tabName = "Search", icon = icon("search"))
)
),
dashboardBody(
tabItems(
tabItem("Search",
fluidRow(
column(4,
hr(),
sliderInput(inputId = "Salary", label = "Expected Salary:",
min = 0, max = 10000,
value = 0, step = 500)),
column(4,
hr(),
selectInput(inputId = 'Industry', label='Industry', c(Choose='', industry), selectize=FALSE)
),
column(4,
hr(),
selectInput(inputId = 'Location', label = 'Location', c(Choose='', Location),selectize=FALSE)
)
),
fluidRow(
column(4,
hr(),
selectInput(inputId = 'Type', label = 'Job type', c(Choose='', jobtype),selectize=FALSE)
),
column(4,
hr(),
selectInput(inputId = 'Skills', label = 'Skills', c(Choose='', skills), selectize=FALSE)
),
column(4,
hr(),
actionButton("search", label = "Search", width = '250px'))
)
)
)
)
)
)
server <- function(input, output, session) {
user_input <- reactive({
#url = "http://localhost:5000"
toJSON(
list(
expected_salary = input$Salary,
industry = input$Industry,
location = input$Location,
expected_hours = input$Type,
skills = input$Skills
),
pretty = TRUE
)})
observeEvent(input$search, {
x <- POST("http://127.0.0.1:5000/recommendation", body = user_input, encode = 'json')
content(x)
})
}
shinyApp(ui, server)
# Run the application
shinyApp(ui = ui, server = server)
We want our r shiny app to pass a json object to our python flask through a post request. The code we have so far is given. We want to send the json file to the url in POST. Currently, when we press search on our shiny app, our app crashes. we think the issue is in how we are using observeEvent function linked to our search button. Any help on how to resolve this is appreciated