Difference between revisions of "Conf/Examples/CgiConfig/TclParamExample"
Jump to navigation
Jump to search
(Created page with ' part of CGI Config Examples') |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
[[Conf/Examples/CgiConfig | part of CGI Config Examples]] | [[Conf/Examples/CgiConfig | part of CGI Config Examples]] | ||
+ | |||
+ | #!/usr/bin/tclsh8.5 | ||
+ | |||
+ | set params [split $env(QUERY_STRING) &] | ||
+ | foreach par $params { | ||
+ | set pair [split $par =] | ||
+ | set name [lindex $pair 0] | ||
+ | set value [lindex $pair 1] | ||
+ | regsub -all \\\+ $value " " value | ||
+ | # Convert url-encoded characters like %20 | ||
+ | regsub -all -nocase {%([0-9a-f][0-9a-f])} $value \ | ||
+ | {[format %c 0x\1]} value | ||
+ | set form($name) [subst $value] | ||
+ | } | ||
+ | |||
+ | puts "Content-type: text/html\n" | ||
+ | |||
+ | puts "<html><head><title>CGI Reply Page - via Tcl</title></head>" | ||
+ | puts "<body bgcolor=white>TCL used in CGI - First Demo" | ||
+ | puts "foo: $form(foo)" | ||
+ | puts "bar: $form(bar)" | ||
+ | puts "</body>" |
Latest revision as of 13:02, 30 December 2011
#!/usr/bin/tclsh8.5
set params [split $env(QUERY_STRING) &] foreach par $params { set pair [split $par =] set name [lindex $pair 0] set value [lindex $pair 1] regsub -all \\\+ $value " " value # Convert url-encoded characters like %20 regsub -all -nocase {%([0-9a-f][0-9a-f])} $value \ {[format %c 0x\1]} value set form($name) [subst $value] }
puts "Content-type: text/html\n"
puts "<html><head><title>CGI Reply Page - via Tcl</title></head>" puts "<body bgcolor=white>TCL used in CGI - First Demo" puts "foo: $form(foo)" puts "bar: $form(bar)" puts "</body>"