当前位置: 首页>>代码示例>>Python>>正文


Python HTTPServer.__init__方法代码示例

本文整理汇总了Python中six.moves.BaseHTTPServer.HTTPServer.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPServer.__init__方法的具体用法?Python HTTPServer.__init__怎么用?Python HTTPServer.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在six.moves.BaseHTTPServer.HTTPServer的用法示例。


在下文中一共展示了HTTPServer.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from six.moves.BaseHTTPServer import HTTPServer [as 别名]
# 或者: from six.moves.BaseHTTPServer.HTTPServer import __init__ [as 别名]
    def __init__(self, boat, behaviour_manager,
                 server_address, RequestHandlerClass, bind_and_activate=True):

        HTTPServer.__init__(self, server_address, RequestHandlerClass,
                            bind_and_activate)
        log.info('boatd api listening on %s:%s', *server_address)

        self.boat = boat
        self.behaviour_manager = behaviour_manager
        self.running = True

        # set API endpoints for GETs
        self.handles = {
            '/': self.boatd_info,
            '/boat': self.boat_attr,
            '/wind': self.wind,
            '/active': self.boat_active,
            '/behaviours': self.behaviours,
        }

        # set API endpoints for POSTs
        self.post_handles = {
            '/': self.boatd_post,
            '/behaviours': self.behaviours_post,
        }
开发者ID:zuzak,项目名称:boatd,代码行数:27,代码来源:api.py

示例2: __init__

# 需要导入模块: from six.moves.BaseHTTPServer import HTTPServer [as 别名]
# 或者: from six.moves.BaseHTTPServer.HTTPServer import __init__ [as 别名]
 def __init__(self, server_address, RequestHandlerClass,
              ssl_context=None, request_queue_size=None):
     # This overrides the implementation of __init__ in python's
     # SocketServer.TCPServer (which BaseHTTPServer.HTTPServer
     # does not override, thankfully).
     HTTPServer.__init__(self, server_address, RequestHandlerClass)
     self.socket = socket.socket(self.address_family,
                                 self.socket_type)
     self.ssl_context = ssl_context
     if ssl_context:
         class TSafeConnection(tsafe.Connection):
             def settimeout(self, *args):
                 self._lock.acquire()
                 try:
                     return self._ssl_conn.settimeout(*args)
                 finally:
                     self._lock.release()
             def gettimeout(self):
                 self._lock.acquire()
                 try:
                     return self._ssl_conn.gettimeout()
                 finally:
                     self._lock.release()
         self.socket = TSafeConnection(ssl_context, self.socket)
     self.server_bind()
     if request_queue_size:
         self.socket.listen(request_queue_size)
     self.server_activate()
开发者ID:crystallovemama,项目名称:hue,代码行数:30,代码来源:httpserver.py

示例3: __init__

# 需要导入模块: from six.moves.BaseHTTPServer import HTTPServer [as 别名]
# 或者: from six.moves.BaseHTTPServer.HTTPServer import __init__ [as 别名]
 def __init__(self, patroni, config):
     self.connection_string = 'http://{}/patroni'.format(config.get('connect_address', None) or config['listen'])
     host, port = config['listen'].split(':')
     HTTPServer.__init__(self, (host, int(port)), RestApiHandler)
     Thread.__init__(self, target=self.serve_forever)
     self._set_fd_cloexec(self.socket)
     self.patroni = patroni
     self.daemon = True
开发者ID:radek-senfeld,项目名称:patroni,代码行数:10,代码来源:api.py

示例4: __init__

# 需要导入模块: from six.moves.BaseHTTPServer import HTTPServer [as 别名]
# 或者: from six.moves.BaseHTTPServer.HTTPServer import __init__ [as 别名]
 def __init__(self, addr, handler, root, userpwd):
     HTTPServer.__init__(self, addr, handler)
     self.root = root
     self.userpwd = userpwd      # WebDAV Auth user:passwd 
     if len(userpwd)>0:
         self.auth_enable = True
     else:
         self.auth_enable = False
开发者ID:prince-0203,项目名称:TinyWebDav,代码行数:10,代码来源:WebDAV.py

示例5: __init__

# 需要导入模块: from six.moves.BaseHTTPServer import HTTPServer [as 别名]
# 或者: from six.moves.BaseHTTPServer.HTTPServer import __init__ [as 别名]
 def __init__(self, server_address, handler, impl, meta):
     '''
     :param server_address: address of the server
     :param handler: handler for requests
     :param impl: reference to the implementation object
     '''
     HTTPServer.__init__(self, server_address, handler)
     self.impl = impl
     self.meta = meta
开发者ID:LucaBongiorni,项目名称:kitty,代码行数:11,代码来源:rpc.py

示例6: __init__

# 需要导入模块: from six.moves.BaseHTTPServer import HTTPServer [as 别名]
# 或者: from six.moves.BaseHTTPServer.HTTPServer import __init__ [as 别名]
    def __init__(self, store, *args, **kwargs):
        HTTPServer.__init__(self, *args, **kwargs)
        self.sessions = {}
        self.store = store

        if self.server_port != 80:
            self.base_url = ('http://%s:%s/' %
                             (self.server_name, self.server_port))
        else:
            self.base_url = 'http://%s/' % (self.server_name,)
开发者ID:ziima,项目名称:python-openid,代码行数:12,代码来源:consumer.py

示例7: __init__

# 需要导入模块: from six.moves.BaseHTTPServer import HTTPServer [as 别名]
# 或者: from six.moves.BaseHTTPServer.HTTPServer import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        HTTPServer.__init__(self, *args, **kwargs)

        if self.server_port != 80:
            self.base_url = ('http://%s:%s/' %
                             (self.server_name, self.server_port))
        else:
            self.base_url = 'http://%s/' % (self.server_name,)

        self.openid = None
        self.approved = {}
        self.lastCheckIDRequest = {}
开发者ID:ziima,项目名称:python-openid,代码行数:14,代码来源:server.py

示例8: __initialize

# 需要导入模块: from six.moves.BaseHTTPServer import HTTPServer [as 别名]
# 或者: from six.moves.BaseHTTPServer.HTTPServer import __init__ [as 别名]
    def __initialize(self, config):
        self.__ssl_options = self.__get_ssl_options(config)
        self.__listen = config['listen']
        host, port = config['listen'].rsplit(':', 1)
        HTTPServer.__init__(self, (host, int(port)), RestApiHandler)
        Thread.__init__(self, target=self.serve_forever)
        self._set_fd_cloexec(self.socket)

        self.__protocol = 'http'

        # wrap socket with ssl if 'certfile' is defined in a config.yaml
        # Sometime it's also needed to pass reference to a 'keyfile'.
        if self.__ssl_options.get('certfile'):
            import ssl
            self.socket = ssl.wrap_socket(self.socket, server_side=True, **self.__ssl_options)
            self.__protocol = 'https'
        self.__set_connection_string(config.get('connect_address'))
开发者ID:jberkus,项目名称:patroni,代码行数:19,代码来源:api.py

示例9: __init__

# 需要导入模块: from six.moves.BaseHTTPServer import HTTPServer [as 别名]
# 或者: from six.moves.BaseHTTPServer.HTTPServer import __init__ [as 别名]
    def __init__(self, patroni, config):
        self._auth_key = base64.b64encode(config['auth'].encode('utf-8')).decode('utf-8') if 'auth' in config else None
        host, port = config['listen'].split(':')
        HTTPServer.__init__(self, (host, int(port)), RestApiHandler)
        Thread.__init__(self, target=self.serve_forever)
        self._set_fd_cloexec(self.socket)

        protocol = 'http'

        # wrap socket with ssl if 'certfile' is defined in a config.yaml
        # Sometime it's also needed to pass reference to a 'keyfile'.
        options = {option: config[option] for option in ['certfile', 'keyfile'] if option in config}
        if options.get('certfile'):
            import ssl
            self.socket = ssl.wrap_socket(self.socket, server_side=True, **options)
            protocol = 'https'

        self.connection_string = '{0}://{1}/patroni'.format(protocol, config.get('connect_address', config['listen']))

        self.patroni = patroni
        self.daemon = True
开发者ID:UKHomeOffice,项目名称:docker-postgres-patroni-not-tracking,代码行数:23,代码来源:api.py

示例10: __init__

# 需要导入模块: from six.moves.BaseHTTPServer import HTTPServer [as 别名]
# 或者: from six.moves.BaseHTTPServer.HTTPServer import __init__ [as 别名]
    def __init__(self, patroni, config):
        self._auth_key = base64.b64encode(config["auth"].encode("utf-8")).decode("utf-8") if "auth" in config else None
        host, port = config["listen"].split(":")
        HTTPServer.__init__(self, (host, int(port)), RestApiHandler)
        Thread.__init__(self, target=self.serve_forever)
        self._set_fd_cloexec(self.socket)

        protocol = "http"

        # wrap socket with ssl if 'certfile' is defined in a config.yaml
        # Sometime it's also needed to pass reference to a 'keyfile'.
        options = {option: config[option] for option in ["certfile", "keyfile"] if option in config}
        if options.get("certfile", None):
            import ssl

            self.socket = ssl.wrap_socket(self.socket, server_side=True, **options)
            protocol = "https"

        self.connection_string = "{}://{}/patroni".format(protocol, config.get("connect_address", config["listen"]))

        self.patroni = patroni
        self.daemon = True
开发者ID:alexclear,项目名称:patroni,代码行数:24,代码来源:api.py

示例11: __init__

# 需要导入模块: from six.moves.BaseHTTPServer import HTTPServer [as 别名]
# 或者: from six.moves.BaseHTTPServer.HTTPServer import __init__ [as 别名]
    def __init__(self, port, session):
        self._logger = logging.getLogger(self.__class__.__name__)

        self.port = port
        self.session = session
        self.vod_fileindex = None
        self.vod_download = None
        self.vod_info = defaultdict(dict)  # A dictionary containing info about the requested VOD streams.

        for _ in xrange(10000):
            try:
                HTTPServer.__init__(self, ("127.0.0.1", self.port), VideoRequestHandler)
                self._logger.debug("Listening at %d", self.port)
                break
            except socket.error:
                self._logger.debug("Listening failed at %d", self.port)
                self.port += 1
                continue

        self.server_thread = None

        self.daemon_threads = True
        self.allow_reuse_address = True
开发者ID:Tribler,项目名称:tribler,代码行数:25,代码来源:VideoServer.py

示例12: __init__

# 需要导入模块: from six.moves.BaseHTTPServer import HTTPServer [as 别名]
# 或者: from six.moves.BaseHTTPServer.HTTPServer import __init__ [as 别名]
 def __init__(self, server_address, RequestHandlerClass, client_id, client_secret, bind_and_activate=True):
     HTTPServer.__init__(self, server_address, RequestHandlerClass, bind_and_activate=bind_and_activate)
     self.logger = logging.getLogger('auth_server.http')
     self.client_id = client_id
     self.client_secret = client_secret
     self.listening_event = threading.Event()
开发者ID:hozn,项目名称:stravalib,代码行数:8,代码来源:auth_responder.py

示例13: __init__

# 需要导入模块: from six.moves.BaseHTTPServer import HTTPServer [as 别名]
# 或者: from six.moves.BaseHTTPServer.HTTPServer import __init__ [as 别名]
 def __init__(self, address, handler):
     HTTPServer.__init__(self, address, handler)
     self.response_queue = queue.Queue()
开发者ID:plone,项目名称:plone.cachepurging,代码行数:5,代码来源:test_purger.py

示例14: do_bind

# 需要导入模块: from six.moves.BaseHTTPServer import HTTPServer [as 别名]
# 或者: from six.moves.BaseHTTPServer.HTTPServer import __init__ [as 别名]
    def do_bind(self):
        """Perform HTTP server binding and activation."""

        HTTPServer.__init__(self, (self.host, self.port), HTTPRequestHandler)
开发者ID:ArthurYV,项目名称:emacs.d,代码行数:6,代码来源:basehttp.py

示例15: __init__

# 需要导入模块: from six.moves.BaseHTTPServer import HTTPServer [as 别名]
# 或者: from six.moves.BaseHTTPServer.HTTPServer import __init__ [as 别名]
 def __init__(self, server_address, request_handler, path):
     self.path = path
     HTTPServer.__init__(self, server_address, request_handler)
开发者ID:sugarlabs,项目名称:sugar-toolkit-gtk3,代码行数:5,代码来源:webkit1.py


注:本文中的six.moves.BaseHTTPServer.HTTPServer.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。