Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4)

Side by Side Diff: Doc/library/http.server.rst

Issue 18758: Fix internal references in the documentation
Patch Set: Created 6 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Doc/library/ftplib.rst ('k') | Doc/library/imaplib.rst » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`http.server` --- HTTP servers 1 :mod:`http.server` --- HTTP servers
2 =================================== 2 ===================================
3 3
4 .. module:: http.server 4 .. module:: http.server
5 :synopsis: HTTP server and request handlers. 5 :synopsis: HTTP server and request handlers.
6 6
7 7
8 .. index:: 8 .. index::
9 pair: WWW; server 9 pair: WWW; server
10 pair: HTTP; protocol 10 pair: HTTP; protocol
(...skipping 11 matching lines...) Expand all
22 handler. Code to create and run the server looks like this:: 22 handler. Code to create and run the server looks like this::
23 23
24 def run(server_class=HTTPServer, handler_class=BaseHTTPRequestHandler): 24 def run(server_class=HTTPServer, handler_class=BaseHTTPRequestHandler):
25 server_address = ('', 8000) 25 server_address = ('', 8000)
26 httpd = server_class(server_address, handler_class) 26 httpd = server_class(server_address, handler_class)
27 httpd.serve_forever() 27 httpd.serve_forever()
28 28
29 29
30 .. class:: HTTPServer(server_address, RequestHandlerClass) 30 .. class:: HTTPServer(server_address, RequestHandlerClass)
31 31
32 This class builds on the :class:`TCPServer` class by storing the server 32 This class builds on the :class:`~socketserver.TCPServer` class by storing th e server
33 address as instance variables named :attr:`server_name` and 33 address as instance variables named :attr:`server_name` and
34 :attr:`server_port`. The server is accessible by the handler, typically 34 :attr:`server_port`. The server is accessible by the handler, typically
35 through the handler's :attr:`server` instance variable. 35 through the handler's :attr:`server` instance variable.
36 36
37 37
38 The :class:`HTTPServer` must be given a *RequestHandlerClass* on instantiation, 38 The :class:`HTTPServer` must be given a *RequestHandlerClass* on instantiation,
39 of which this module provides three different variants: 39 of which this module provides three different variants:
40 40
41 .. class:: BaseHTTPRequestHandler(request, client_address, server) 41 .. class:: BaseHTTPRequestHandler(request, client_address, server)
42 42
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 .. method:: do_GET() 319 .. method:: do_GET()
320 320
321 The request is mapped to a local file by interpreting the request as a 321 The request is mapped to a local file by interpreting the request as a
322 path relative to the current working directory. 322 path relative to the current working directory.
323 323
324 If the request was mapped to a directory, the directory is checked for a 324 If the request was mapped to a directory, the directory is checked for a
325 file named ``index.html`` or ``index.htm`` (in that order). If found, the 325 file named ``index.html`` or ``index.htm`` (in that order). If found, the
326 file's contents are returned; otherwise a directory listing is generated 326 file's contents are returned; otherwise a directory listing is generated
327 by calling the :meth:`list_directory` method. This method uses 327 by calling the :meth:`list_directory` method. This method uses
328 :func:`os.listdir` to scan the directory, and returns a ``404`` error 328 :func:`os.listdir` to scan the directory, and returns a ``404`` error
329 response if the :func:`listdir` fails. 329 response if the :func:`~os.listdir` fails.
330 330
331 If the request was mapped to a file, it is opened and the contents are 331 If the request was mapped to a file, it is opened and the contents are
332 returned. Any :exc:`OSError` exception in opening the requested file is 332 returned. Any :exc:`OSError` exception in opening the requested file is
333 mapped to a ``404``, ``'File not found'`` error. Otherwise, the content 333 mapped to a ``404``, ``'File not found'`` error. Otherwise, the content
334 type is guessed by calling the :meth:`guess_type` method, which in turn 334 type is guessed by calling the :meth:`guess_type` method, which in turn
335 uses the *extensions_map* variable. 335 uses the *extensions_map* variable.
336 336
337 A ``'Content-type:'`` header with the guessed content type is output, 337 A ``'Content-type:'`` header with the guessed content type is output,
338 followed by a ``'Content-Length:'`` header with the file's size and a 338 followed by a ``'Content-Length:'`` header with the file's size and a
339 ``'Last-Modified:'`` header with the file's modification time. 339 ``'Last-Modified:'`` header with the file's modification time.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 to POST to a non-CGI url. 416 to POST to a non-CGI url.
417 417
418 Note that CGI scripts will be run with UID of user nobody, for security 418 Note that CGI scripts will be run with UID of user nobody, for security
419 reasons. Problems with the CGI script will be translated to error 403. 419 reasons. Problems with the CGI script will be translated to error 403.
420 420
421 :class:`CGIHTTPRequestHandler` can be enabled in the command line by passing 421 :class:`CGIHTTPRequestHandler` can be enabled in the command line by passing
422 the ``--cgi`` option.:: 422 the ``--cgi`` option.::
423 423
424 python -m http.server --cgi 8000 424 python -m http.server --cgi 8000
425 425
OLDNEW
« no previous file with comments | « Doc/library/ftplib.rst ('k') | Doc/library/imaplib.rst » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+