diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2000-08-25 22:36:13 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2000-08-25 22:36:13 (GMT) |
commit | ab0280d252fa64d7027d36868989a923a7fcf218 (patch) | |
tree | 2ad3f9e0fddc37324dd35eda23dc5b3915dbae8e /Mac/Tools | |
parent | be80fa2f5d0c8365c094edeab4c24905383d18bc (diff) | |
download | cpython-ab0280d252fa64d7027d36868989a923a7fcf218.zip cpython-ab0280d252fa64d7027d36868989a923a7fcf218.tar.gz cpython-ab0280d252fa64d7027d36868989a923a7fcf218.tar.bz2 |
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.
Diffstat (limited to 'Mac/Tools')
-rw-r--r-- | Mac/Tools/CGI/cgi.html | 53 |
1 files changed, 53 insertions, 0 deletions
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 @@ +<HTML> +<HEAD> + <META NAME="GENERATOR" CONTENT="Adobe PageMill 3.0 Mac"> + <TITLE>Creating CGI scripts with MacPython</TITLE> +</HEAD> +<BODY> + +<H3>Creating CGI scripts with MacPython</H3> +<BLOCKQUOTE> +Note: this document is work-in-progress, and not tested. +</BLOCKQUOTE> + +<P>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 <TT>os.environ</TT> +and sending their results to <TT>stdout</TT>. 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).</P> + +<P>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.</P> + +<P>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.</P> + +<P>The next step is to tell the webserver that documents with +a ".<TT>py</TT>" extension should be served through +the <TT>PythonCGISlave</TT> helper application. Open the webserver, +choose Preferences, tab Action, Add, Start on Extension, extension +".py", select application <TT>PythonCGISlave</TT> (which +lives in <TT>Python:Mac:Tools:CGI</TT>).</P> + +<P>The last step is to try it. Put the following script in <TT>Macintosh +HD:Webpages:hello.py </TT>(assuming your webserver has the default +settings for its document folder):</P> + +<BLOCKQUOTE> + <P><CODE>print "Content-type: text/plain"<BR> + print<BR> + print "Hello world!"<BR> + import time<BR> + print "Local time is", time.ctime(time.time())</CODE></P></BLOCKQUOTE> + +<P>Point your webbrowser at <A HREF="http://localhost/hello.py">http://localhost/hello.py</A><CODE> +</CODE>and check whether it works. + +</BODY> +</HTML> |