Re: Using SF as a CGI

From: Appert, Kevin <kevin.appert_at_lmco.com>
Date: Fri, 06 Dec 2002 14:46:14 -0800

>Lastly, TinyWEB wants the CGI to run as a console application.
        In SF parlance, this means a Text Window with no extra "stuff" -
like a DOS box with access to the Windows API, network layer and
        and other kernel functions. I assume that TinyWeb wants this
instead of a full-up Windows application.

I believe all the early SF examples were Console Applications.

An example of a Console Application:
http://www.fdisk.com/doslynx/lynxport.htm

> -----Original Message-----
> From: Bob Nash [SMTP:BNash_at_smud.org]
> Sent: Friday, December 06, 2002 2:25 PM
> To: SFTALK (E-mail)
> Subject: [sftalk] Using SF as a CGI
>
>
> 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.
----------------------------------------------------------------------
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:45:43 PST


Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!

This archive was generated 09-Feb-2012. Archive updated nightly.