Language:EN
Pages: 2
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
this module obtains the current time the web

This module obtains the current time the web

pythonhtp1_06.fm Page 199 Saturday, December 8, 2001 1:27 PM

Chapter 6

On the other hand, Web browsers cache server responses to get requests. With a Web-based search engine, a get request normally supplies the search engine with search criteria specified in an XHTML form. The search engine then performs the search and returns the results as a Web page. These pages are cached in the event that the user performs the same search again.

The server normally sends one or more HTTP headers, which provide additional infor-mation about the data sent in response to the request. In this case, the server is sending an HTML/XHTML text document, so the HTTP header reads

This information is known as the MIME (Multipurpose Internet Mail Extensions) type of
the content. MIME is an Internet standard that specifies how messages should be formatted,
and clients use the content type to determine how to represent the content to the user. Each
type of data sent has a MIME type associated with it that helps the browser determine how
to process the data it receives. For example, the MIME type text/plain indicates that
the data is text that should be displayed without attempting to interpret any of the content
as HTML or XHTML markup. Similarly, the MIME type image/gif indicates that the
content is a GIF(Graphics Interchange Format) image. When this MIME type is received

The header (or set of headers) is followed by a blank line (a carriage return, line feed or

combination of both) which indicates to the client that the server is finished sending HTTP
headers. The server then sends the text in the requested HTML/XHTML document (down-
loads.html). The connection terminates when the transfer of the resource completes. The

client-side browser interprets the text it receives and displays (or renders) the results.

browser application on the client side (e.g., Microsoft Internet Explorer or Netscape Com-
municator) and a Web-server application on the server side (e.g., Apache or IIS). Next, we
Two types of scripting are used in Web-based applications: server-side and client-side. CGI
scripts are an example of server-side scripts because they run on the server. Programmers
have greater control over Web page content when using server-side scripts, because server-
side scripts can manipulate databases and other server resources. An example of client-side
scripting is JavaScript. Client-side scripts can access the browser’s features, manipulate

browser documents, validate user input and much more.

Scripts executed on the server usually generate custom responses for clients. For

example, a client might connect to an airline’s Web server and request a list of all flights
from Boston to San Antonio between September 19th and November 5th. The server que-
ries the database, dynamically generates XHTML content containing the flight list and
sends the XHTML to the client. This technology allows clients to obtain the most current
200

Introduction to the Common Gateway Interface (CGI)

Chapter 6

Server-side scripting languages have a wider range of programmatic capabilities than their client-side equivalents. For example, server-side scripts can access the server’s file directory structure, whereas client-side scripts cannot access the client’s file directory structure.

to the client. 6.1

As long as a file on the server remains unchanged, its associated URL will display the

same content in clients’ browsers each time the file is accessed. For the content in the file
to change (e.g., to include new links or the latest company news), someone must alter the
file manually (probably with a text editor or Web-page design software) then load the

changed file back onto the server.

and dynamic Web pages. For example, if you want your Web page always to display the
(CSS). CSS allows document authors to specify the presentation of elements on a Web page
(spacing, margins, etc.) separately from the structure of the document (section headers,
body text, links, etc.). Readers not familiar with these technologies will want to read
Appendix I and Appendix J, which describe XHTML in detail and Appendix K, Cascading

Figure 6.3 illustrates the full program listing for our first CGI script. Line 1

#!c:\Python\python.exe

depending on the location of the Python interpreter. [Note: If you do not know where the Python interpreter resides, contact the server administrator.]

Common Programming Error 6.1

6.1
server and displays it in the user’s browser. Lines 7–17 define function printHeader.
This function takes argument title, which corresponds to the title of the Web page. Line

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : Marcus Little-Holloway

PageId: ELIABDA16C