Rook (version 1.1-1)

Rhttpd-class: Class Rhttpd

Description

Rhttpd is a convenience class for installing and running Rook applications. It hides the details of starting and stopping the server and adding and removing Rook applications from the server.

Users starts by creating one Rhttpd object, then adding applications to it, and then starting the server (see the section Examples for a typical session). There are no restrictions on creating more than one server object, but know that it only manages the applications that are added to it and not others.

Applications can be added and removed regardless of whether or not the server is running. Stopping the server does not remove any applications. Adding an application with the same name as one already installed simply overwrites the one installed. If the server is started with no applications installed, it will install the application named RookTestApp located in:

system.file('exampleApps/RookTestApp.R',package='Rook').

Also, see browseURL to learn how to get R to automatically launch your favorite web browser.

NOTE: This version of Rook can only listen on the loopback device.

Arguments

See Also

RhttpdApp

Examples

# Create an Rhttpd object and start the internal web server. Note that
# if there are no applications added, then the default RookTest app in
# system.file('exampleApps/RookTestApp.R',package='Rook') is automatically
# added.

s <- Rhttpd$new()
s$start(quiet=TRUE)
s$browse(1)
s$print()

# Be sure to install the Hmisc package before installing and running
# this application. You will want to; it's a pretty good one.
# s$add(
#    app=system.file('exampleApps/Hmisc/config.R',package='Rook'),
#    name='hmisc')

s$add(
    app=system.file('exampleApps/helloworld.R',package='Rook'),
    name='hello'
)
s$add(
    app=system.file('exampleApps/helloworldref.R',package='Rook'),
    name='helloref'
)
s$add(
    app=system.file('exampleApps/summary.R',package='Rook'),
    name='summary'
)

s$print()

#  Stops the server but doesn't uninstall the app
s$stop()
s$remove(all=TRUE)
rm(s)