File:  [gforth] / gforth / gforth-cgi.fs
Revision 1.1: download - view: text, annotated - select for diffs
Fri Mar 2 11:14:59 2007 UTC (17 years, 1 month ago) by anton
Branches: MAIN
CVS tags: v0-7-0, HEAD
added example cgi script

    1: #! /usr/bin/gforth
    2: 
    3: \ This file is in the public domain. NO WARRANTY.
    4: 
    5: \ Example CGI script
    6: 
    7: .( Content-Type: text/plain; charset=us-ascii) cr
    8: .( Content-Transfer-Encoding: 7bit) cr
    9: cr
   10: : zeroes ( u -- )
   11:     0 +do '0 emit loop ;
   12: 
   13: : u.rz ( u1 u2 -- )
   14:     >r s>d  <<# #s #> r> over - zeroes type #>> ;
   15: 
   16: .( It's ) time&date 4 u.rz .( -) 2 u.rz .( -) 2 u.rz space
   17:                     2 u.rz .( :) 2 u.rz .( :) 2 u.rz cr
   18: \ : printargs ( -- )
   19: \     argc @ 0 +do
   20: \         ." arg" i . ." = '" i arg type ." '" cr
   21: \     loop ;
   22: \ printargs
   23: \ s" QUERY_STRING" getenv type cr
   24: \ s" PATH_INFO" getenv type cr
   25: \ s" PATH_TRANSLATED" getenv type
   26: \ s" CONTENT_LENGTH" getenv type
   27: bye

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>