Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
21572fdc
Kaydet (Commit)
21572fdc
authored
Haz 14, 1999
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
New sections from Moshe Zadka <moshez@math.huji.ac.il>.
These document CGIHTTPServer, SimpleHTTPServer, and linecache.
üst
d5258681
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
173 additions
and
0 deletions
+173
-0
libcgihttp.tex
Doc/lib/libcgihttp.tex
+61
-0
liblinecache.tex
Doc/lib/liblinecache.tex
+41
-0
libsimplehttp.tex
Doc/lib/libsimplehttp.tex
+71
-0
No files found.
Doc/lib/libcgihttp.tex
0 → 100644
Dosyayı görüntüle @
21572fdc
\section
{
\module
{
CGIHTTPServer
}
---
A Do-Something Request Handler
}
\declaremodule
{
standard
}{
CGIHTTPServer
}
\sectionauthor
{
Moshe Zadka
}{
mzadka@geocities.com
}
\modulesynopsis
{
This module provides a request handler for HTTP servers
which can run CGI scripts.
}
The
\module
{
CGIHTTPServer
}
module defines a request-handler class,
interface compatible with
\class
{
BaseHTTPServer.BaseHTTPRequestHandler
}
and inherits behaviour
from
\class
{
SimpleHTTPServer.SimpleHTTPRequestHandler
}
but can also
run CGI scripts.
The
\module
{
CGIHTTPServer
}
module defines the following class:
\begin{classdesc}
{
CGIHTTPRequestHandler
}{
request, client
_
address, server
}
This class is used to serve either files or output of CGI scripts from
the current directory and below. Note that mapping HTTP hierarchic
structure to local directory structure is exactly as in
\class
{
SimpleHTTPServer.SimpleHTTPRequestHandler
}
.
The class will however, run the CGI script, instead of serving it as a
file, if it guesses it to be a CGI script. Only directory-based CGI
are used --- the other common server configuration is to treat special
extensions as denoting CGI scripts.
The
\function
{
do
_
GET()
}
and
\function
{
do
_
HEAD()
}
functions are
modified to run CGI scripts and serve the output, instead of serving
files, if the request leads to somewhere below the
\code
{
cgi
_
directories
}
path.
\end{classdesc}
The
\class
{
CGIHTTPRequestHandler
}
defines the following data member:
\begin{memberdesc}
{
cgi
_
directories
}
This defaults to
\code
{
['/cgi-bin', '/htbin']
}
and describes
directories to treat as containing CGI scripts.
\end{memberdesc}
The
\class
{
CGIHTTPRequestHandler
}
defines the following methods:
\begin{methoddesc}
{
do
_
POST
}{}
This method serves the
\code
{
'POST'
}
request type, only allowed for
CGI scripts. Error 501, "Can only POST to CGI scripts", is output
when trying to POST to a non-CGI url.
\end{methoddesc}
Note that CGI scripts will be run with UID of user nobody, for security
reasons. Problems with the CGI script will be translated to error 403.
For example usage, see the implementation of the
\function
{
test()
}
function.
\begin{seealso}
\seemodule
{
BaseHTTPServer
}{
Base class implementation for Web server
and request handler.
}
\end{seealso}
Doc/lib/liblinecache.tex
0 → 100644
Dosyayı görüntüle @
21572fdc
\section
{
\module
{
linecache
}
---
Treat files like lists of lines
}
\declaremodule
{
standard
}{
linecache
}
\sectionauthor
{
Moshe Zadka
}{
mzadka@geocities.com
}
\modulesynopsis
{
This module treats files like random-access lists of lines.
}
The
\module
{
linecache
}
module allows one to get any line from any file,
while attempting to optimize internally, using a cache, the common case
where many lines are read from a file.
The
\module
{
linecache
}
module defines the following functions:
\begin{funcdesc}
{
getline
}{
filename, lineno
}
Get line
\var
{
lineno
}
from file named
\var
{
filename
}
. This function
will never throw an exception --- it will return
\code
{
''
}
on errors.
If a file named
\var
{
filename
}
is not found, the function will look
for it in the module search path.
\end{funcdesc}
\begin{funcdesc}
{
clearcache
}{}
Clear the cache. You might want to use this function if you know that
you do not need to read lines from many of files you already read from
using this module.
\end{funcdesc}
\begin{funcdesc}
{
checkcache
}{}
Check the cache is still valid. You might want to use this function if
you suspect that files you read from using this module might have
changed.
\end{funcdesc}
Example:
\begin{verbatim}
>>> import linecache
>>> linecache.getline('/etc/passwd', 4)
'sys:x:3:3:sys:/dev:/bin/sh
\0
12'
\end{verbatim}
Doc/lib/libsimplehttp.tex
0 → 100644
Dosyayı görüntüle @
21572fdc
\section
{
\module
{
SimpleHTTPServer
}
---
A Do-Something Request Handler
}
\declaremodule
{
standard
}{
SimpleHTTPServer
}
\sectionauthor
{
Moshe Zadka
}{
mzadka@geocities.com
}
\modulesynopsis
{
This module provides a request handler for HTTP servers.
}
The
\module
{
SimpleHTTPServer
}
module defines a request-handler class,
interface compatible with
\class
{
BaseHTTPServer.BaseHTTPRequestHandler
}
which serves files only from a base directory.
The
\module
{
SimpleHTTPServer
}
module defines the following class:
\begin{classdesc}
{
SimpleHTTPRequestHandler
}{
request, client
_
address, server
}
This class is used, to serve files from current directory and below,
directly mapping the directory structure to HTTP requests.
A lot of the work is done by the base class
\class
{
BaseHTTPServer.BaseHTTPRequestHandler
}
, such as parsing the
request. This class implements the
\function
{
do
_
GET()
}
and
\function
{
do
_
HEAD()
}
functions.
\end{classdesc}
The
\class
{
SimpleHTTPRequestHandler
}
defines the following member
variables:
\begin{memberdesc}
{
server
_
version
}
This will be
\code
{
"SimpleHTTP/" +
__
version
__}
, where
\code
{__
version
__}
is defined in the module.
\end{memberdesc}
\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
}
.
The mapping is used case-insensitively, and so should contain only
lower-cased keys.
\end{memberdesc}
The
\class
{
SimpleHTTPRequestHandler
}
defines the following methods:
\begin{methoddesc}
{
do
_
HEAD
}{}
This method serves the
\code
{
'HEAD'
}
request type: it sends the
headers it would send for the equivalent
\code
{
GET
}
request. See the
\method
{
do
_
GET()
}
method for more complete explanation of the possible
headers.
\end{methoddesc}
\begin{methoddesc}
{
do
_
GET
}{}
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.
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.
For example usage, see the implementation of the
\function
{
test()
}
function.
\end{methoddesc}
\begin{seealso}
\seemodule
{
BaseHTTPServer
}{
Base class implementation for Web server
and request handler.
}
\end{seealso}
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