From ab0280d252fa64d7027d36868989a923a7fcf218 Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Fri, 25 Aug 2000 22:36:13 +0000 Subject: How-to document for using Python for CGI scripting. Not complete and untested, but I'm checking it in so it won't get lost. --- Mac/Tools/CGI/cgi.html | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Mac/Tools/CGI/cgi.html diff --git a/Mac/Tools/CGI/cgi.html b/Mac/Tools/CGI/cgi.html new file mode 100644 index 0000000..3dc5dc0 --- /dev/null +++ b/Mac/Tools/CGI/cgi.html @@ -0,0 +1,53 @@ + + + + Creating CGI scripts with MacPython + + + +

Creating CGI scripts with MacPython

+
+Note: this document is work-in-progress, and not tested. +
+ +

MacPython allows you to use Python as a CGI scripting language +for your webserver. Moreover, there are some helper applications +that allow you to write your CGI scripts in the same way as for +Unix and Windows, i.e. obtaining their arguments from os.environ +and sending their results to stdout. MacPython also has +all the facilities to program CGI scripts in the Macintosh way, +through AppleEvents, but that falls outside the scope of this +document (reading the source code for the helper scripts will +give you an idea about how to do this).

+ +

For the purpose of this document we will assume you are using +Apple's Personal Webserver 1.5, which comes standard with your +machine as of MacOS 9.

+ +

The first step is to start the webserver, you will find it +in your control panels. Give it a folder to serve documents from, +and check that it is working by pointing your browser at it.

+ +

The next step is to tell the webserver that documents with +a ".py" extension should be served through +the PythonCGISlave helper application. Open the webserver, +choose Preferences, tab Action, Add, Start on Extension, extension +".py", select application PythonCGISlave (which +lives in Python:Mac:Tools:CGI).

+ +

The last step is to try it. Put the following script in Macintosh +HD:Webpages:hello.py (assuming your webserver has the default +settings for its document folder):

+ +
+

print "Content-type: text/plain"
+ print
+ print "Hello world!"
+ import time
+ print "Local time is", time.ctime(time.time())

+ +

Point your webbrowser at http://localhost/hello.py +and check whether it works. + + + -- cgit v0.12