SimpleHTTPServer (version: 0.3)
Simple HTTP Server.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
||Simple HTTP request handler with GET and HEAD commands.|
This serves files from the current directory and any of its
subdirectories. It assumes that all files are plain text files
unless they have the extension ".html" in which case it assumes
they are HTML files.
The GET and HEAD requests are identical except that the HEAD
request omits the actual contents of the file.
- copyfile(self, source, outputfile)
- Copy all data between two file objects.
- The SOURCE argument is a file object open for reading
- (or anything with a read() method) and the DESTINATION
- argument is a file object open for writing (or
- anything with a write() method).
- The only reason for overriding this would be to change
- the block size or perhaps to replace newlines by CRLF
- -- note however that this the default server uses this
- to copy binary data as well.
- Serve a GET request.
- Serve a HEAD request.
- guess_type(self, path)
- Guess the type of a file.
- Argument is a PATH (a filename).
- Return value is a string of the form type/subtype,
- usable for a MIME Content-type header.
- The default implementation looks the file's extension
- up in the table self.extensions_map, using text/plain
- as a default; however it would be permissible (if
- slow) to look inside the data to make a better guess.
- Common code for GET and HEAD commands.
- This sends the response code and MIME headers.
- Return value is either a file object (which has to be copied
- to the outputfile by the caller unless the command was HEAD,
- and must be closed by the caller under all circumstances), or
- None, in which case the caller has nothing further to do.
- translate_path(self, path)
- Translate a /-separated PATH to the local filename syntax.
- Components that mean special things to the local file system
- (e.g. drive or directory names) are ignored. (XXX They should
- probably be diagnosed.)