localServerStart {gWidgetsWWW}R Documentation

Function to interact with local web server

Description

The gWidgetsWWW package allows gWidgets scripts to be run through a web browser. For wider deployment, the package can be run through the RApache package. To develop scripts and to run scripts standalone, the local server may be used.

The local web server accompanying gWidgetsWWW is controlled through 4 functions to start, stop, restart and open a file. The local web server is a Tcl script, modified from the Rpad package, that runs through the tcltk package. It provides access to gWidgetsWWW files through the 127.0.0.1 IP only.

Usage

localServerStart(file = "", port = 8079, package = NULL)

localServerStop()

localServerRestart()

localServerOpen(file, package)

gWidgetsWWWIsLocal()

Arguments

file Name of file to open. If no package is specified, this is a file relative to the directory returned by getwd. If the package argument is given, then the file is found from the call system.file(file, package=package).
port Port to run on. URLs are of the form 127.0.0.1:port.
package If specified, files are found reltive to this package through system.file(file,package=package).

Details

If no file is specified to localServerStart then a directory listing of all R files in the current working directory (getwd) is given.

Files can be of many types depending on the url: If the URL does not start with gWidgetsWWWrun or gWidgetsWWWRunFromPackage then the file is served as is. These can be html files, or svg files, png files, ...

If the url is of the type: http://127.0.0.1/gWidgetsWWWrun/filename.R then it is assumed the file is a gWidgetsWWW script and it will be so run.

If the url is of the type: http://127.0.0.1/gWidgetsWWWRunFromPackage/filename.R?package=packagename then the file is found from system.file(filename.R, package=packagename) and then run as a gWidgetsWWW script.

The local server borrows that from the Rpad package. It is a modified Tcl script and runs under the tcltk package. This script handles escaping of backslashed slightly differently than the Apache server, so there may be issues arising. To check to see if the script is being executed locally use gWidgetsWWWIsLocal.

There is no way to send information to the browser from the R console. The browser must initiate the request.

The local server logs error messages in the console.

The local server will only respond to requests that originate from the localhost (127.0.0.1). This is a security measure.

Value

For localServerStart and localServerOpen a new browser page is opened.

Author(s)

John Verzani

References

The Rpad modifications were made by Tom Short. The original Tcl code is from the tclhttpd project http://www.tcl.tk/software/tclhttpd/

See Also

Rpad

Examples

        ## Not run: 
        localServerStart()      # opens browser with files in working directory
        localServerOpen(file="Examples/ex-ggooglemaps.R", package="gWidgetsWWW")
        
## End(Not run)

[Package gWidgetsWWW version 0.0-14 Index]