本文整理汇总了Python中http.server.HTTPServer.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPServer.__init__方法的具体用法?Python HTTPServer.__init__怎么用?Python HTTPServer.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类http.server.HTTPServer
的用法示例。
在下文中一共展示了HTTPServer.__init__方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from http.server import HTTPServer [as 别名]
# 或者: from http.server.HTTPServer import __init__ [as 别名]
def __init__(
self,
host,
port,
app,
processes=40,
handler=None,
passthrough_errors=False,
ssl_context=None,
fd=None,
):
if not can_fork:
raise ValueError("Your platform does not support forking.")
BaseWSGIServer.__init__(
self, host, port, app, handler, passthrough_errors, ssl_context, fd
)
self.max_children = processes
示例2: __init__
# 需要导入模块: from http.server import HTTPServer [as 别名]
# 或者: from http.server.HTTPServer import __init__ [as 别名]
def __init__(self, addr, handler, poll_interval=0.5,
log=False, sslctx=None):
class DelegatingHTTPRequestHandler(BaseHTTPRequestHandler):
def __getattr__(self, name, default=None):
if name.startswith('do_'):
return self.process_request
raise AttributeError(name)
def process_request(self):
self.server._handler(self)
def log_message(self, format, *args):
if log:
super(DelegatingHTTPRequestHandler,
self).log_message(format, *args)
HTTPServer.__init__(self, addr, DelegatingHTTPRequestHandler)
ControlMixin.__init__(self, handler, poll_interval)
self.sslctx = sslctx
示例3: __init__
# 需要导入模块: from http.server import HTTPServer [as 别名]
# 或者: from http.server.HTTPServer import __init__ [as 别名]
def __init__(self):
self.hostname = None
self.port = None
#这是请求
self.command = None
self.path = None
self.request_version = None
#这是响应
self.response_version = None
self.status = None
self.reason = None
self._headers = None
self._body = b''
示例4: __init__
# 需要导入模块: from http.server import HTTPServer [as 别名]
# 或者: from http.server.HTTPServer import __init__ [as 别名]
def __init__(self, host, port, app, handler=None,
passthrough_errors=False, ssl_context=None):
if handler is None:
handler = WSGIRequestHandler
self.address_family = select_ip_version(host, port)
HTTPServer.__init__(self, (host, int(port)), handler)
self.app = app
self.passthrough_errors = passthrough_errors
self.shutdown_signal = False
if ssl_context is not None:
if isinstance(ssl_context, tuple):
ssl_context = load_ssl_context(*ssl_context)
if ssl_context == 'adhoc':
ssl_context = generate_adhoc_ssl_context()
self.socket = ssl_context.wrap_socket(self.socket,
server_side=True)
self.ssl_context = ssl_context
else:
self.ssl_context = None
示例5: __init__
# 需要导入模块: from http.server import HTTPServer [as 别名]
# 或者: from http.server.HTTPServer import __init__ [as 别名]
def __init__(self, protocol):
self._protocol = protocol
self._certfile = None
self._keyfile = None
self._password = None
示例6: __init__
# 需要导入模块: from http.server import HTTPServer [as 别名]
# 或者: from http.server.HTTPServer import __init__ [as 别名]
def __init__(self, file):
BytesIO.__init__(self)
self.wrappedFile = file
示例7: __init__
# 需要导入模块: from http.server import HTTPServer [as 别名]
# 或者: from http.server.HTTPServer import __init__ [as 别名]
def __init__(self, rfile):
self._rfile = rfile
self._done = False
self._len = 0
示例8: __init__
# 需要导入模块: from http.server import HTTPServer [as 别名]
# 或者: from http.server.HTTPServer import __init__ [as 别名]
def __init__(self, RequestHandlerClass=ProxyRequestHandler, **kwargs):
# Save off proxy specific options
self.target_host = kwargs.pop('target_host', None)
self.target_port = kwargs.pop('target_port', None)
self.wrap_cmd = kwargs.pop('wrap_cmd', None)
self.wrap_mode = kwargs.pop('wrap_mode', None)
self.unix_target = kwargs.pop('unix_target', None)
self.ssl_target = kwargs.pop('ssl_target', None)
self.token_plugin = kwargs.pop('token_plugin', None)
self.auth_plugin = kwargs.pop('auth_plugin', None)
self.heartbeat = kwargs.pop('heartbeat', None)
self.token_plugin = None
self.auth_plugin = None
self.daemon = False
# Server configuration
listen_host = kwargs.pop('listen_host', '')
listen_port = kwargs.pop('listen_port', None)
web = kwargs.pop('web', '')
# Configuration affecting base request handler
self.only_upgrade = not web
self.verbose = kwargs.pop('verbose', False)
record = kwargs.pop('record', '')
if record:
self.record = os.path.abspath(record)
self.run_once = kwargs.pop('run_once', False)
self.handler_id = 0
for arg in kwargs.keys():
print("warning: option %s ignored when using --libserver" % arg)
if web:
os.chdir(web)
HTTPServer.__init__(self, (listen_host, listen_port),
RequestHandlerClass)