本文整理汇总了Python中BaseHTTPServer.test方法的典型用法代码示例。如果您正苦于以下问题:Python BaseHTTPServer.test方法的具体用法?Python BaseHTTPServer.test怎么用?Python BaseHTTPServer.test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseHTTPServer
的用法示例。
在下文中一共展示了BaseHTTPServer.test方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: import BaseHTTPServer [as 别名]
# 或者: from BaseHTTPServer import test [as 别名]
def test(HandlerClass = SimpleHTTPRequestHandler,
ServerClass = BaseHTTPServer.HTTPServer):
"""Run the HTTP request handler class.
This runs an HTTP server on port 8000 (or the first command line
argument).
"""
parse_options()
server_address = ('0.0.0.0', SERVER_PORT)
SimpleHTTPRequestHandler.protocol_version = "HTTP/1.0"
httpd = BaseHTTPServer.HTTPServer(server_address, SimpleHTTPRequestHandler)
sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd.serve_forever()
BaseHTTPServer.test(HandlerClass, ServerClass)
示例2: test
# 需要导入模块: import BaseHTTPServer [as 别名]
# 或者: from BaseHTTPServer import test [as 别名]
def test(HandlerClass = SimpleHTTPRequestHandler,
ServerClass = BaseHTTPServer.HTTPServer):
BaseHTTPServer.test(HandlerClass, ServerClass)
示例3: test
# 需要导入模块: import BaseHTTPServer [as 别名]
# 或者: from BaseHTTPServer import test [as 别名]
def test(HandlerClass = googleCacheHandler,
ServerClass = BaseHTTPServer.HTTPServer):
BaseHTTPServer.test(HandlerClass, ServerClass)
示例4: main
# 需要导入模块: import BaseHTTPServer [as 别名]
# 或者: from BaseHTTPServer import test [as 别名]
def main():
# BaseHTTPServer.test(SimpleHTTPRequestHandler, BaseHTTPServer.HTTPServer)
if sys.argv[1:]:
port = int(sys.argv[1])
else:
port = 8000
server_address = ('', port)
SimpleHTTPRequestHandler.protocol_version = "HTTP/1.0"
httpd = BaseHTTPServer.HTTPServer(server_address, SimpleHTTPRequestHandler)
sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd.serve_forever()