Re: CGI?
Re: CGI?
- Subject: Re: CGI?
- From: Michelle Steiner <email@hidden>
- Date: Thu, 12 Apr 2001 17:12:56 -0700
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
Where does it get saved, though? In a script file, in the html page? If
the former, how do I access it from the page? if the latter, where in
the page?
>
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? What would I use for "server:
MacHTTP" for personal web sharing instead of the MacHTTP server?
>
The full response would then look so:
>
return http_OK_header & myStaticPagePart1 & myCounterValue &
>
myStaticPagePart2
Where does this go?
I just can't figure out any of it right now.
--Michelle
----------------------------------------------------------------------
| Michelle Steiner | We're not human beings having a spiritual |
| | experience. We're spiritual beings |
| email@hidden | having a human experience. |
----------------------------------------------------------------------
- Follow-Ups:
- Re: CGI?
- From: cris <email@hidden>
- Re: CGI?
- From: Sander Tekelenburg <email@hidden>