Re: CGI?
Re: CGI?
- Subject: Re: CGI?
- From: cris <email@hidden>
- Date: Fri, 13 Apr 2001 20:13:02 +0200
on 13.04.2001 2:12 Uhr, Michelle Steiner at email@hidden wrote:
>
On 4/12/01 3:31 PM, cris <email@hidden> wrote:
>
>
> Open the standard additions and look at the 'handle CGI request' under
>
> 'Internet suite'.
>
>
>
> If you just want to have a counter you can ignore all the optional
>
> parameters and just put your script code into the handler.
>
>
Like this:
>
>
on handle CGI request
>
set FileID to open for access file "dora:counter" with write permission
>
if (get eof FileID) is not 0 then
>
set NumberOfAccess to read FileID
>
else
>
set NumberOfAccess to 0
>
end if
>
set NumberOfAccess to NumberOfAccess + 1
>
set eof FileID to 0
>
write (NumberOfAccess as text) to FileID
>
close access FileID
>
return NumberOfAccess
>
end handle CGI request
Yes, but you need to change the return statement to:
return http_OK_header & myStaticPagePart1 & myCounterValue &
myStaticPagePart2
If you don't provide the response type to the webserver i guess it will just
end in an error.
>
Where does it get saved, though? In a script file, in the html page?
In a stay-open script which name ends with ".acgi" so it is recognized by
the webserver as a executable CGI application.
>
If
>
the former, how do I access it from the page?
http://yourIPAddress/cgi-bin/myCounterScript.acgi
Where the name of the "cgi-bin" folder can vary from server to server..
"cgi-bin" is the name of the Webstar CGI folder.
>
> At the end of the handler you have to return back something to the webserver
>
> (which will pass it to the browser). You need to specify the type of
>
> response in the header. In this case it will be a '200 OK' which looks so:
>
>
>
> property CRLF : (ASCII character 13) & (ASCII character 10)
>
> property http_OK_header : "HTTP/1.0 200 OK" & CRLF & "Server: MacHTTP" &
>
> CRLF & "MIME-Version: 1.0" & CRLF & "Content-type: text/html" & CRLF & CRLF
>
>
This goes in the header of the HTML page?
Yes, the HTML page created within your CGI, passed to the webserver which
will send it to the browser.
>
What would I use for "server:
>
MacHTTP" for personal web sharing instead of the MacHTTP server?
I think you can let it just unchanged.
>
> The full response would then look so:
>
> return http_OK_header & myStaticPagePart1 & myCounterValue &
>
> myStaticPagePart2
>
>
Where does this go?
At the end of the 'handle CGI request' handler.
Greetings
cris :-)
--
English is my second language.
www.cooc.de
References: | |
| >Re: CGI? (From: Michelle Steiner <email@hidden>) |