Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
4cbe95cd
Commit
4cbe95cd
authored
Aug 07, 2004
by
Andrew M. Kuchling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bug #866222] Update docs to match the module
parent
b839c1f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
7 deletions
+15
-7
Doc/lib/libsimplehttp.tex
Doc/lib/libsimplehttp.tex
+15
-7
No files found.
Doc/lib/libsimplehttp.tex
View file @
4cbe95cd
...
...
@@ -33,7 +33,7 @@ is defined in the module.
\begin{memberdesc}
{
extensions
_
map
}
A dictionary mapping suffixes into MIME types. Default is signified
by an empty string, and is considered to be
\code
{
text/plain
}
.
by an empty string, and is considered to be
\code
{
application/octet-stream
}
.
The mapping is used case-insensitively, and so should contain only
lower-cased keys.
\end{memberdesc}
...
...
@@ -51,15 +51,23 @@ headers.
The request is mapped to a local file by interpreting the request as
a path relative to the current working directory.
If the request was mapped to a directory, a
\code
{
403
}
respond is output,
followed by the explanation
\code
{
'Directory listing not supported'
}
.
Any
\exception
{
IOError
}
exception in opening the requested file, is mapped
to a
\code
{
404
}
,
\code
{
'File not found'
}
error. Otherwise, the content
type is guessed using the
\var
{
extensions
_
map
}
variable.
If the request was mapped to a directory, the directory is checked for
a file named
\code
{
index.html
}
or
\code
{
index.htm
}
(in that order).
If found, the file's contents are returned; otherwise a directory
listing is generated by calling the
\method
{
list
_
directory()
}
method.
This method uses
\function
{
os.listdir()
}
to scan the directory, and
returns a
\code
{
404
}
error response if the
\function
{
listdir()
}
fails.
If the request was mapped to a file, it is opened and the contents are
returned. Any
\exception
{
IOError
}
exception in opening the requested
file is mapped to a
\code
{
404
}
,
\code
{
'File not found'
}
error. Otherwise, the content type is guessed using the
\var
{
extensions
_
map
}
variable.
A
\code
{
'Content-type:'
}
with the guessed content type is output, and
then a blank line, signifying end of headers, and then the contents of
the file. The file is always opened in binary mode.
the file. If the file's MIME type starts with
\code
{
text/
}
the file is
opened in text mode; otherwise binary mode is used.
For example usage, see the implementation of the
\function
{
test()
}
function.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment