How to know if the app is running at local or on server? (R Shiny) -


i test app on laptop, , deploy shinyapps server. before deploying, need remove statement setting path, e.g.,

setwd('/users/mry/onedrive/data') 

is there way code can find out if it's running locally or on server, like:

if (islocal()) {        setwd('/users/mry/onedrive/data') } 

a trivial sample code (it fail on server if setwd isn't removed):

server.r

library(shiny)  setwd('/users/yuji/onedrive/data/townstate')    data = 'data1.csv'  # test, using empty .csv file  shinyserver(function(input, output) {   })  

ui.r

library(shiny)  shinyui(pagewithsidebar(     headerpanel("click button"),      sidebarpanel(         actionbutton("gobutton", "go!")     ),     mainpanel(      ) )) 

the standard way in shiny with: sys.getenv('shiny_port'). write like:

is_local <- sys.getenv('shiny_port') == "" 

Comments