MacHTTP Examples

All of these scripts and CGI applications can be found in the "Examples" folder within the Tutorials folder. If you don't have the Script Editor application from the full AppleScript distribution, you should only use the ".script" examples since you won't be able to modify the ".cgi" ones.

Testing Forms, Searches, and Maps

Many times, it is necessary to find out what arguments are being sent from a WWW client to MacHTTP. Clicking on an image as part of a map, or filling in a form and submitting it can send data that is hard to capture. The following two examples can be used as the ACTION for a form, or the anchor for a map or search request. These two scripts extract all of the parameters passed from MacHTTP to CGI applications and scripts, formats them as HTML, and returns the results to your WWW client

Passing the following URL to test.script demonstrates the various parts of a MacHTTP URL:
http://your.host.address/Tutorials/Examples/test.script$Path%20Arguments?Search+Args

Simple Map Example

This example shows how to build a simple, clickable map. There are better tools for this than AppleScript, but this script shows how to process arguments and more importantly, it demonstrates the URL Redirection technique.


Interfacing MacHTTP to other programming languages

Interfacing MacHTTP to other languages - MacHTTP can communicate with other scripting languages like HyperCard, Perl, or even C and Pascal programs. In the Examples folder, inside the Tutorials folder is a folder called HyperCard CGI demo. This folder contains a sample HyperCard stack, demo form, and instructions for calling HyperCard stacks from MacHTTP.

Using MacPerl is another way to provide scripting services to MacHTTP, and it has the added benefit of being portable to Unix.

Finally, it is fairly easy to develop custom C code to handle special interface tasks for MacHTTP. Check the "Examples" page off the MacHTTP Home Page for details.


Remote Server Administration

In the Examples folder, within the Tutorials folder, is a file called machttp_admin.cgi.sit. This file is a AppleScript CGI application, written by Jonathan Bell, that allows you to administer MacHTTP remotely from any WWW client. Because this is a potential security risk, the file must be unstuffed before you can use it. It is HIGHLY recommended that you immediately add a security realm to protect this file from unauthorized use. See the Security tutorial for more details.

To use this CGI, simply reference its URL from any WWW client. It will automatically generate a form that allows you to modify many of MacHTTP's settings.