mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
be80fa2f5d
commit
ab0280d252
1 changed files with 53 additions and 0 deletions
53
Mac/Tools/CGI/cgi.html
Normal file
53
Mac/Tools/CGI/cgi.html
Normal file
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue