Description Usage Arguments Details Value Note References Examples
A request object is created from the appropriate environment variables and is returned as a list. List elements include:
params – list of request parameters
headers – list of HTTP headers
method – "GET"
raw – NULL
content_type – NULL
protocol – "http"
body – NULL
1 | cgiRequest(testParams = NULL)
|
testParams |
URL request parameters for testing GET requests |
Even in the modern era (>= 2017) it is still sometimes useful to build simple web services using CGI scripts. Benefits include: ease of coding; use of standard port 80; service uptime: even if the CGI script dies while handling an earlier request, the script will be restarted for the next request.
Using this function, the body of an R CGI script can begin with:
1 2 3 4 | req <- cgiRequest()
headers <- req$params
params <- req$params
...
|
A list containing CGI request elements
The returned object mimics the request object created in the jug package.
https://github.com/Bart6114/jug/blob/master/R/request.R
1 2 3 4 | # Example borrowed from webutils::parse_query
q <- "foo=1%2B1%3D2&bar=yin%26yang"
req <- cgiRequest(q)
str(req$params)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.