sample cgi?
Jan Schenkel
janschenkel at yahoo.com
Wed Jul 31 15:13:01 EDT 2002
Hi Kee,
If it works in HyperCard it should work for Revolution
as well, since Revolution has full support for
AppleEvent-technologies.
In this case I'd say it's a matter of having your
webserver poke RunRev or a stand-alone instead of
HyperCard.
If you're talking about getting the cgi-server up and
running, your best bet is to look at Tip of the Week
number 6 on the RunRev website:
http://www.runrev.com/revolution/developers/articles/tipoftheweek/6.html
It shows how to use "split" to parse the data passed
to it from the browser.
Or maybe I got your question wrong :-)
Jan Schenkel.
"As we grow older, we grow both wiser and more foolish
at the same time." (De Rochefoucald)
--- Kee Nethery <kee at kagi.com> wrote:
> Never got an answer to this question so I figure I
> should perhaps ask it again.
>
> Does someone have the standard sample cgi in
> Revolution that returns
> a web page that displays all the parameters that the
> browser sends to
> the server?
>
> In HyperTalk the stack script that catches all the
> data from the web
> server via AppleEvents is shown below. The
> HandleOrder script takes
> some of the data and parses it and creates an HTML
> reply.
>
> These two scripts are the complete cycle for a
> HyperCard based cgi.
>
> Can someone show me a Revolution example? I'm hoping
> that the
> Revolution example also deals with cookies but a
> simple example sans
> cookies would be better than nothing.
>
> Thanks, Kee
>
>
> on AppleEvent class, ID, sender
> -- Here is where we receive the event, pull off
> the relevant
> -- information, and send it off to be processed.
> --
> -- The following is a list of the MacHTTP
> parameters
> -- that are available, should you need to use
> them:
> --
> --'addr' - client address
> --'Agnt' - user agent
> --'ctyp' - content type
> --'frmu' - from user
> --'kfor' - search arguments
> --'meth' - HTTP method
> --'pass' - the user password
> --'post' - post arguments
> --'refr' - referer
> --'scnm' - script name
> --'svnm' - server name
> --'svpt' - server port
> --'user' - user name
> --
>
> if class & ID is "WWWsdoc" then
> -- this is the CGI gateway "sdoc" message. We
> need to check this first to
> -- distinguish it from the Finder's, other
> application's AppleEvents that
> -- might also be sent to HyperCard.
>
> -- Pull up the basic AppleEvent data. This is
> dummy information in
> -- our case.
> request appleEvent data -- get the direct
> parameter (path args)
>
> -- Now get the "POST" message. This is the
> important information s
> -- which contain all the settings from the form
> going to this cgi.
> request appleEvent data with keyword "post"
> put it into orderValues
>
> -- Get the address of the sender (good for
> tracking usage)
> request appleEvent data with keyword "addr"
> put it into customerTCPAddress
>
> HandleOrder orderValues, customerTCPAddress
> else
> pass appleEvent
> end if
> end AppleEvent
>
>
> on HandleOrder orderValues, customerTCPAddress
> -- This routine parses the information we picked
> up from the
> -- AppleEvents (above) and forms the reply which
> is nothing
> -- more than another HTML page description.
>
>
> ----------------------------------------------------
> -- First, parse the order information into parts
>
> ----------------------------------------------------
> set the itemDelimiter to "&" -- Each item will be
> separated by a "&"
> put item 1 of orderValues into dogCowSizeLine
> put item 2 of orderValues into dogCowQuantityLine
> put item 3 of orderValues into
> dogCowShipMethodLine
> put item 4 of orderValues into wholesaleOrderLine
>
> set the itemDelimiter to "="
> -- This makes it easy to separate the names of the
> values from their value
> -- e.g. "quantity=on"
>
> put the last item of dogCowSizeLine into
> dogCowSize
> put the last item of dogCowQuantityLine into
> orderQuantity
> put the last item of dogCowShipMethodLine into
> shipMethod
> put the last item of wholesaleOrderLine into
> wholesaleOrder
> -- Check for exact value of wholesale, as this
> parameter may be
> -- missing entirely if not checked.
> if wholesaleOrder = "on" then
> put true into isWholesale
> else
> put false into isWholesale
> end if
>
>
> ----------------------------------------------------
> -- Now see if the DogCow is in stock
>
> ----------------------------------------------------
> find dogCowSize in cd fld "DogCow Size"
> put word 2 of the foundLine into selectedSizeLine
> put line selectedSizeLine of cd fld "Wholesale
> Price" into wholesalePrice
> put line selectedSizeLine of cd fld "Retail Price"
> into retailPrice
> put line selectedSizeLine of cd fld "Qty.
> Available" into qtyAvailable
> put (orderQuantity <= qtyAvailable) into inStock
>
> if not inStock then
> put "<B>Requested Quantity: </B>" & orderQuantity
> & "<BR>" into theMessage
> if qtyAvailable = 1 then
> put "Only one" && dogCowSize && "DogCow
> available." after theMessage
> else
> put "Only " & qtyAvailable && dogCowSize &&
> "DogCows." after theMessage
> end if
> else
> -- Tally up pricing
> if isWholesale then
> put wholesalePrice into sellingPrice
> else
> put retailPrice into sellingPrice
> end if
>
> if shipMethod = "Regular" then
> put cd fld "Regular Shipping Charge" into
> shipPrice
> else
> put cd fld "Express Shipping Charge" into
> shipPrice
> end if
>
> -- Decrement "inventory"
> subtract orderQuantity from line selectedSizeLine
> of cd fld "Qty.
> Available"
>
> -- Give total message
> set the numberFormat to "###,###,###,##0.00"
> put (orderQuantity * sellingPrice) + shipPrice
> into totalPrice
> put "<B>Your order total comes to: </B>" &
> totalPrice into theMessage
> end if
> put "<P>" & theMessage & "</P>" after orderText
>
>
> ----------------------------------------------------
> -- Assemble and display message
>
> ----------------------------------------------------
> put "<HEAD><TITLE>Order
> Information</TITLE></HEAD>" into theHeader
> put "<BODY><H1>Order Information</H1>" into
> bodyText
> put "<B>Ordered by: </B>" & customerTCPAddress &
> orderText after bodyText
> put "<P>Thanks for using the DogCow Ordering
> System!</P>" after bodyText
> put "</BODY>" after bodyText
> put "<HTML>" & theHeader & bodyText &
> "</HTML>"into theResult
> reply theResult
> end HandleOrder
> _______________________________________________
>
=== message truncated ===
__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com
More information about the use-livecode
mailing list