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
1251fafc
Commit
1251fafc
authored
Jun 03, 2012
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue 14989: http.server --cgi option can enable the CGI http server.
parent
c68e1368
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
7 deletions
+24
-7
Doc/library/http.server.rst
Doc/library/http.server.rst
+6
-0
Lib/http/server.py
Lib/http/server.py
+15
-7
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/http.server.rst
View file @
1251fafc
...
@@ -400,3 +400,9 @@ the previous example, this serves files relative to the current directory. ::
...
@@ -400,3 +400,9 @@ the previous example, this serves files relative to the current directory. ::
Note that CGI scripts will be run with UID of user nobody, for security
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.
reasons. Problems with the CGI script will be translated to error 403.
:class:`CGIHTTPRequestHandler` can be enabled in the command line by passing
the ``--cgi`` option.::
python -m http.server --cgi 8000
Lib/http/server.py
View file @
1251fafc
...
@@ -100,6 +100,8 @@ import sys
...
@@ -100,6 +100,8 @@ import sys
import
time
import
time
import
urllib.parse
import
urllib.parse
import
copy
import
copy
import
argparse
# Default error message template
# Default error message template
DEFAULT_ERROR_MESSAGE
=
"""
\
DEFAULT_ERROR_MESSAGE
=
"""
\
...
@@ -1173,18 +1175,13 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
...
@@ -1173,18 +1175,13 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
def
test
(
HandlerClass
=
BaseHTTPRequestHandler
,
def
test
(
HandlerClass
=
BaseHTTPRequestHandler
,
ServerClass
=
HTTPServer
,
protocol
=
"HTTP/1.0"
):
ServerClass
=
HTTPServer
,
protocol
=
"HTTP/1.0"
,
port
=
8000
):
"""Test the HTTP request handler class.
"""Test the HTTP request handler class.
This runs an HTTP server on port 8000 (or the first command line
This runs an HTTP server on port 8000 (or the first command line
argument).
argument).
"""
"""
if
sys
.
argv
[
1
:]:
port
=
int
(
sys
.
argv
[
1
])
else
:
port
=
8000
server_address
=
(
''
,
port
)
server_address
=
(
''
,
port
)
HandlerClass
.
protocol_version
=
protocol
HandlerClass
.
protocol_version
=
protocol
...
@@ -1200,4 +1197,15 @@ def test(HandlerClass = BaseHTTPRequestHandler,
...
@@ -1200,4 +1197,15 @@ def test(HandlerClass = BaseHTTPRequestHandler,
sys
.
exit
(
0
)
sys
.
exit
(
0
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test
(
HandlerClass
=
SimpleHTTPRequestHandler
)
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--cgi'
,
action
=
'store_true'
,
help
=
'Run as CGI Server'
)
parser
.
add_argument
(
'port'
,
action
=
'store'
,
default
=
8000
,
type
=
int
,
nargs
=
'?'
,
help
=
'Specify alternate port [default: 8000]'
)
args
=
parser
.
parse_args
()
if
args
.
cgi
:
test
(
HandlerClass
=
CGIHTTPRequestHandler
,
port
=
args
.
port
)
else
:
test
(
HandlerClass
=
SimpleHTTPRequestHandler
,
port
=
args
.
port
)
Misc/NEWS
View file @
1251fafc
...
@@ -10,6 +10,9 @@ What's New in Python 3.3.0 Beta 1?
...
@@ -10,6 +10,9 @@ What's New in Python 3.3.0 Beta 1?
Library
Library
-------
-------
- Issue #14989: Make the CGI enable option to http.server available via command
line.
- Issue #14987: Add a missing import statement to inspect.
- Issue #14987: Add a missing import statement to inspect.
- Issue #1079: email.header.decode_header now correctly parses all the examples
- Issue #1079: email.header.decode_header now correctly parses all the examples
...
...
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