翻译仅为个人学习,商业版权与此无关!::-- nickcheng [2007-01-25 10:20:05]

1. Chapter 21. CGI Scripting and Alternatives

When a web browser (or any other web client) requests a page from a web server, the server may return either static or dynamic content. Serving dynamic content involves server-side web programs to generate and deliver content on the fly, often based on information stored in a database. The long-standing web-wide standard for server-side programming is known as CGI, which stands for Common Gateway Interface:

  1. A web client (typically a browser) sends a structured request to a web server.
  2. The server executes another program, passing the content of the request.
  3. The server captures the standard output of the other program.
  4. The server sends that output to the client as the response to the original request.

In other words, the server's role is that of a gateway between the client and the other program. The other program is called a CGI program, or CGI script.

CGI enjoys the typical advantages of standards. When you program to the CGI standard, your program can be deployed on all web servers, and work despite the differences. This chapter focuses on CGI scripting in Python. It also mentions the downsides of CGI (basically, issues of scalability under high load) and, in "Other Server-Side Approaches" on page 557, some of the many alternative, nonstandard server-side architectures that you can use instead of CGI. Nowadays, the nonstandard alternatives are often superior because they do not constrain your deployment much, and they can support higher-level abstractions to enhance productivity. (For example, use cookies implicitly and transparently to provide a "session" abstraction (while in CGI you must deal with cookies directly if you want any session continuity) with the Cookie module covered in "The Cookie Module" on page 553). However, at least for low-level CGI alternatives (such as FastCGI, mentioned in "FastCGI" on page 557), most of what you learn about CGI programming still comes in handy.

This chapter assumes familiarity with HTML and HTTP. For reference material on these standards, see Webmaster in a Nutshell, by Stephen Spainhour and Robert Eckstein (O'Reilly). For detailed coverage of HTML, I recommend HTML & XHTML: The Definitive Guide, by Chuck Musciano and Bill Kennedy (O'Reilly). For additional coverage of HTTP, see the HTTP Pocket Reference, by Clinton Wong (O'Reilly).

1.1. 讨论 Discussion

2. 评译

Name Password4deL ;) =D =) :P :(|) :-| :( X-( B-)
nickcheng   段落之间空行还真的不好整啊! 我现在是加两个[[BR]], 有更好的方法么?
2007-01-25 22:49:39