Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / html / python / lib / cgi-intro.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="node471.html" />
13<link rel="prev" href="module-cgi.html" />
14<link rel="parent" href="module-cgi.html" />
15<link rel="next" href="node471.html" />
16<meta name='aesop' content='information' />
17<title>11.2.1 Introduction</title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="11.2 cgi "
25 href="module-cgi.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="11.2 cgi "
28 href="module-cgi.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="11.2.2 Using the cgi"
31 href="node471.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python Library Reference</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="module-cgi.html">11.2 cgi </A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="module-cgi.html">11.2 cgi </A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="node471.html">11.2.2 Using the cgi</A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H2><A NAME="SECTION0013210000000000000000">
5611.2.1 Introduction</A>
57</H2>
58<A NAME="cgi-intro"></A>
59<P>
60A CGI script is invoked by an HTTP server, usually to process user
61input submitted through an HTML <code>&lt;FORM&gt;</code> or <code>&lt;ISINDEX&gt;</code> element.
62
63<P>
64Most often, CGI scripts live in the server's special <span class="file">cgi-bin</span>
65directory. The HTTP server places all sorts of information about the
66request (such as the client's hostname, the requested URL, the query
67string, and lots of other goodies) in the script's shell environment,
68executes the script, and sends the script's output back to the client.
69
70<P>
71The script's input is connected to the client too, and sometimes the
72form data is read this way; at other times the form data is passed via
73the ``query string'' part of the URL. This module is intended
74to take care of the different cases and provide a simpler interface to
75the Python script. It also provides a number of utilities that help
76in debugging scripts, and the latest addition is support for file
77uploads from a form (if your browser supports it -- Grail 0.3 and
78Netscape 2.0 do).
79
80<P>
81The output of a CGI script should consist of two sections, separated
82by a blank line. The first section contains a number of headers,
83telling the client what kind of data is following. Python code to
84generate a minimal header section looks like this:
85
86<P>
87<div class="verbatim"><pre>
88print "Content-Type: text/html" # HTML is following
89print # blank line, end of headers
90</pre></div>
91
92<P>
93The second section is usually HTML, which allows the client software
94to display nicely formatted text with header, in-line images, etc.
95Here's Python code that prints a simple piece of HTML:
96
97<P>
98<div class="verbatim"><pre>
99print "&lt;TITLE&gt;CGI script output&lt;/TITLE&gt;"
100print "&lt;H1&gt;This is my first CGI script&lt;/H1&gt;"
101print "Hello, world!"
102</pre></div>
103
104<P>
105
106<DIV CLASS="navigation">
107<div class='online-navigation'>
108<p></p><hr />
109<table align="center" width="100%" cellpadding="0" cellspacing="2">
110<tr>
111<td class='online-navigation'><a rel="prev" title="11.2 cgi "
112 href="module-cgi.html"><img src='../icons/previous.png'
113 border='0' height='32' alt='Previous Page' width='32' /></A></td>
114<td class='online-navigation'><a rel="parent" title="11.2 cgi "
115 href="module-cgi.html"><img src='../icons/up.png'
116 border='0' height='32' alt='Up One Level' width='32' /></A></td>
117<td class='online-navigation'><a rel="next" title="11.2.2 Using the cgi"
118 href="node471.html"><img src='../icons/next.png'
119 border='0' height='32' alt='Next Page' width='32' /></A></td>
120<td align="center" width="100%">Python Library Reference</td>
121<td class='online-navigation'><a rel="contents" title="Table of Contents"
122 href="contents.html"><img src='../icons/contents.png'
123 border='0' height='32' alt='Contents' width='32' /></A></td>
124<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
125 border='0' height='32' alt='Module Index' width='32' /></a></td>
126<td class='online-navigation'><a rel="index" title="Index"
127 href="genindex.html"><img src='../icons/index.png'
128 border='0' height='32' alt='Index' width='32' /></A></td>
129</tr></table>
130<div class='online-navigation'>
131<b class="navlabel">Previous:</b>
132<a class="sectref" rel="prev" href="module-cgi.html">11.2 cgi </A>
133<b class="navlabel">Up:</b>
134<a class="sectref" rel="parent" href="module-cgi.html">11.2 cgi </A>
135<b class="navlabel">Next:</b>
136<a class="sectref" rel="next" href="node471.html">11.2.2 Using the cgi</A>
137</div>
138</div>
139<hr />
140<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
141</DIV>
142<!--End of Navigation Panel-->
143<ADDRESS>
144See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
145</ADDRESS>
146</BODY>
147</HTML>