![]() |
||
| Home | SwiftForth Archive | SwiftX Archive | |

I am interested in using SF as a CGI. I would like to generate minimal html
pages in response to a GET method passed to a tiny HTTP server on my home
LAN. I was wondering if anyone had done something like this with SF that
they could share.
Specifically, I would like to know if I am on the right path with STDIN,
STDOUT and environment variables.
First, I assume that I just make the API call to get a handle to STDOUT and
treat it like a normal file. For example: "STD_OUTPUT_HANDLE GetStdHandle."
>From what I can tell, STDOUT is how the HTML pages that my app generates are
passed to the HTTP server. Am I on the right track here?
Second, I assume that when the HTTP server starts up my app, it passes it
environment variables containing the query from the remote PC. The
environment variables passed from the HTTP server are strings such as
QUERY_STRING and CONTENT_LENGTH. Some time ago, Mike Ghan provided a
snippet to do get the environment variable string:
\ Function: GetEnvironmentVariable ( lpName lpBuffer nBufSize -- #chars )
: GET-ENV ( name len -- addr cnt )
R-BUF R@ ZPLACE R> ( envName )
0 0 >QPAD ( buf ) 128 GetEnvironmentVariable
QPAD SWAP ;
He suggested using GETV and GETC to parse the returned string for the
variables. I assume the variables are prefixed with an identifier (e.g.,
something like QUERY_STRING="foobar"). Does anyone know what I might expect
back?
It appears that at least one mini HTTP server allows you to specify the CGI
executable to use in response to a particular file extension (e.g.,
myForthCGI.exe for .f extensions). Does anyone have a recommendation for a
good mini HTTP server? I have looked at TinyWEB and another more full
featured one out of Russia. These are for Win32 and executables are under
100K.
Lastly, TinyWEB wants the CGI to run as a console application. I am not
sure what this means and how to do it. I do not plan to register a window
or anything like that, just output HTML on STDOUT and terminate. Is there
something I should know here?
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe sftalk" to listar_at_forth.com
For help with listar commands, send subject "help" to listar_at_forth.com
Archives are located at http://www.forth.com/sftalk -- check them out!
Search the archives! Visit http://www.forth.com/search for details.
Received on Fri Dec 06 2002 - 14:24:10 PST
This archive was generated by hypermail 2.2.0 : Fri Nov 21 2008 - 03:04:25 PST