Hi All,
I am trying to use Rook to first:
1)Serve a static web page in an HTML file
2)After that static page is loaded in the browser, then have javascript within the web page retrieve info from Rook via GET and POST
Serving up a static web page works fine (code below) but then how do
I find the http address for constructing the GET/POST commands?
A query string like this does not seem to work:
The issue is how to get the address of the running "script" that will answer a get/post query?
My understanding is that normally the script location string will be given by the
variable (env$SCRIPT_NAME) that is defined in the Rook app function, but
how to access this when serving a static HTML page? Any insights would be appreciated.
Thanks,
Greg
#######Code#####################################
## Use a Builder to add a
staticApp <- Builder$new(
Static$new(
urls=c('/app', '/app/library'),
root = file.path(getwd(), "..", "..")
),
App$new(function(env) {
req <- Request$new(env)
res <- Response$new()
getstr <<- paste(capture.output(str(req$GET()),file=NULL),collapse='\n')
res$finish()
})
)
s <- Rhttpd$new(); # Create server
s$add(app=staticApp, name="static")
s$start(port=9000)