Creating Web Servers
You already know that CGI request processing involves Web servers and clients. Usually, we use browsers, such as Netscape Navigator and Internet Explorer, as Web clients. The most popular Web servers are IIS, Apache, and Netscape. You can use Python for creating a Web server and Web clients. Some of the modules available in Python for building Web servers are SocketServer, BaseHTTPServer, SimpleHTTPServer, and CGIHTTPServer. The SocketServer module is used for creating general IP servers. It...
Packages
In Python, packages allow you to create a hierarchical file directory structure of modules by using dotted module names. For example, mymodule.mod1 stands for a module, mod1, in the package mymodule. You already know that the same function and variable names can be used in different modules. You use fully qualified names to address these functions and variables in the same module. Similarly, modules with the same names can exist in different packages and are referred with dotted module names....
The urllipurlopen Function
The urlopen function retrieves a Web page and returns a file-like object that can be manipulated the way any other file object can be manipulated. The syntax of the urlopen function is this The urlopen function opens the URL url. For HTTP GET requests, a query string should be provided as part of url. You will learn about encoding data in the next section, the urlencode function. For POST requests, because data is to be kept a secret, it is not passed as part of url. Instead, encoded data is...
The socket Module
To implement network programming in Python by using sockets, you use the socket module. It contains various methods used for socket-based network programming. The most common of them is the socket method. The socket method is used to create a new socket. It returns the socket object, which is an instance of the SocketType class. The syntax of the socket method is as follows You can have the family value as AF_UNIX or AF_INET. AF in AF_UNIX and AF_INET stand for Address Family. These family...

