First R3 CGI script

Carl Sassenrath, CTO
REBOL Technologies
28-Mar-2009 22:27 GMT

Article #0182
Main page || Index || Prior Article [0181] || Next Article [0183] || Post Comments || Send feedback

As a simple test of progress on R3 development, I wrote a small CGI script for this Linux server.

Since R3 does not contain a special CGI startup mode (no -c option), I added a short loop to obtain the CGI environment variables. And, it only needs to request the variables that the script actually needs.

Here's the example script:

#!./r3 -q
REBOL [Title: "R3 CGI Env Test"]

print "Content-type: text/html^/"

cgi-env: object [

foreach word words-of cgi-env [
    str: uppercase to-string word
    replace str #"-" #"_"
    if val: get-env str [set in cgi-env word val]

print ajoin [
    <link rel='stylesheet' href=''>
    <h1> "R3 CGI Test" </h1>
    <p> "Date:" now </p>
    <p> "Vers:" system/version </p>
    <pre> cgi-env </pre>

So, if you want to see other CGI variables, just add another word to the cgi-env object.

Try it out: R3 CGI Test

Now that R3 has modules, it would be good to add a small CGI support module (as a built-in) that provides some of the main functions most users want from CGI. We've already created most of these for R2, and I think they will work in R3 with minor changes. It would be useful to provide them as a standard module.

Post Comments

Updated 14-Jun-2024 - Edit - Copyright REBOL Technologies -