本文整理匯總了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()