I've been writing some CGI programs in Pop-11, and have some utilities
I could send to anyone interested.
These include:
parse_cgi_input() -> property
A procedure for converting the arguments to a CGI program into a
Pop-11 property. Works with either GET or POST data. E.g. if the
CGI program is invoked as:
cgi-bin/myprog?arg1=foo&arg2=baz
a property like this is created:
newmapping([['arg1' 'foo'] ['arg2' 'baz']], ...)
write_html_template(filename, property)
Filename should contain HTML formatted text, which is written to
standard output. As this occurs, instances of:
$var$
in the file are replaced by the string associated with 'var' in
the property. Also, instances of:
$proc()$
are replaced with the result of calling the procedure associated
with the 'proc' in the property.
The upshot of all this is that you could write a `Greet' CGI program as
follows:
Create file `greet.p':
define main();
lvars prop;
parse_cgi_input() -> prop;
oneof(['Hello' 'Greetings' 'Welcome']) -> prop('greet');
write_template('greet.template', prop)
enddefine;
Compile with:
popc -e main -o cgi-bin/greet greet.p
Create file `greet.template'
<HTML>
<HEAD> <TITLE> $greet$ </TITLE> </HEAD>
<BODY>
<P>
$greet$ $name$!
</BODY>
</HTML>
This CGI program could be invoked with the argument "Fred" by the URL:
cgi-bin/greet?name=Fred
I hope this is (a) comprehensible (b) useful!
John.
|