CGI in Mac Classic (8.6)

LiangTyan Fui mlist at afteroffice.com
Thu Jun 26 02:51:00 EDT 2003


On 6/26/03 9:25 AM, "Alain Farmer" <alain_farmer at yahoo.com> wrote:

> Hello everyone,
> 
> I have created dozens of HyperCard-based CGI programs.
> I am good at it. But as you all know HyperCard only
> runs on a Mac and, more to the point, Mac-based CGI
> programs react to the web by handling a particular
> Apple event, e.g. on AppleEvent. And the CGI ends with
> the command "reply" once the HTML has been built
> line-by-line. My problem is adapting this knowledge to
> MetaCard on the same Mac. This is specifically what I
> need to know:
> 
> 1. Does MetaCard implement CGIs on a MacOS-Classic
> (8.6) by supporting the same "on appleEvent" mechanism
> ?
> 
> 2. Is "get appleEvent data with <keyword>" supported?
> 
> 3. Can I convert my HyperCard-based CGI to a MC-based
> CGI merely by opening my HC-stack with MetaCard?
> 
> 4. Are there one or more ready-made examples of
> MC-based CGI programs for MacOS-Classic?
> 
> 5. What is the minimal set of HTTP-response-headers
> that CGIs created with MetaCard 2.4+ are required to
> provide? Btw these headers were not necessary in MC
> 2.3, but now they are essential.
> 
> Thanks you kindly for any help you may provide me to
> get over this initial hurdle in my mastery of
> MetaCard. I've created an entire GUI with MetaCard
> (e.g. FreeGUI), and I am currently creating three
> blogging stacks (2 clients and a server), but, so far,
> I have not mastered its CGI abilities. Please help me
> ( a fellow altruist who will be sharing his blogging
> stacks with the MC community ).
> 
> Regards,
> 
> Alain Farmer
> 
> PS: A working sample script would be ideal.  :)

Stripped from my very old archive.
You sure you still want to use OS 9 for CGI?

#! master handle here to capture event from WebSTAR
on appleEvent class, eventID, sender
  if class & eventID <> "WWW‡sdoc" then pass appleEvent
  put unpackCGI() into theHTML
  
  reply "HTTP/1.0 200 OK"& crlf \
       &"Server: MC/2.3 ID/ACGI"& crlf \
       &"MIME-Version: 1.0"& crlf \
       &"Content-type: text/html"& crlf \
       &"Content-Length: "& length(theHTML) & crlf & crlf & theHTML
end appleEvent

function unpackCGI
  # available AppleEvent:
  put 
"----,kfor,refr,Agnt,Kact,Kapt,post,meth,Kfrq,svnm,svpt,ctyp,Kcid,Kcip" into
aeList
  
  put "" into theHTML
  repeat for each item aeEvent in aeList
    request appleEvent data with keyword aeEvent
    put aeEvent &"=" it & cr after theHTML
  end repeat
  
  return theHTML
end unpackCGI





More information about the metacard mailing list