Python http.server.HTTPServer.__init__() Examples
The following are 30
code examples of http.server.HTTPServer.__init__().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
http.server.HTTPServer
, or try the search function
.
Example #1
Source File: test_logging.py From ironpython3 with Apache License 2.0 | 7 votes |
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
Example #2
Source File: test_logging.py From ironpython3 with Apache License 2.0 | 6 votes |
def __init__(self, addr, handler, poll_interval=0.5, bind_and_activate=True): class DelegatingUDPRequestHandler(DatagramRequestHandler): def handle(self): self.server._handler(self) def finish(self): data = self.wfile.getvalue() if data: try: super(DelegatingUDPRequestHandler, self).finish() except OSError: if not self.server._closed: raise ThreadingUDPServer.__init__(self, addr, DelegatingUDPRequestHandler, bind_and_activate) ControlMixin.__init__(self, handler, poll_interval) self._closed = False
Example #3
Source File: serving.py From recruit with Apache License 2.0 | 6 votes |
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
Example #4
Source File: proxy.py From BaseProxy with GNU General Public License v2.0 | 6 votes |
def __init__(self, request,proxy_socket): HttpTransfer.__init__(self) self.request = request h = HTTPResponse(proxy_socket) h.begin() ##HTTPResponse会将所有chunk拼接到一起,因此会直接得到所有内容,所以不能有Transfer-Encoding del h.msg['Transfer-Encoding'] del h.msg['Content-Length'] self.response_version =self.version_dict[h.version] self.status = h.status self.reason = h.reason self.set_headers(h.msg) body_data = self._decode_content_body(h.read(),self.get_header('Content-Encoding')) self.set_body_data(body_data) self._text()#尝试将文本进行解码 h.close() proxy_socket.close()
Example #5
Source File: serving.py From Flask-P2P with MIT License | 6 votes |
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
Example #6
Source File: test_logging.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
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
Example #7
Source File: test_logging.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def __init__(self, addr, handler, poll_interval=0.5, bind_and_activate=True): class DelegatingUDPRequestHandler(DatagramRequestHandler): def handle(self): self.server._handler(self) def finish(self): data = self.wfile.getvalue() if data: try: super(DelegatingUDPRequestHandler, self).finish() except OSError: if not self.server._closed: raise ThreadingUDPServer.__init__(self, addr, DelegatingUDPRequestHandler, bind_and_activate) ControlMixin.__init__(self, handler, poll_interval) self._closed = False
Example #8
Source File: proxy.py From BaseProxy with GNU General Public License v2.0 | 6 votes |
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''
Example #9
Source File: serving.py From Building-Recommendation-Systems-with-Python with MIT License | 6 votes |
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
Example #10
Source File: serving.py From Building-Recommendation-Systems-with-Python with MIT License | 6 votes |
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
Example #11
Source File: serving.py From scylla with Apache License 2.0 | 6 votes |
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
Example #12
Source File: serving.py From Flask-P2P with MIT License | 5 votes |
def __init__(self, host, port, app, processes=40, handler=None, passthrough_errors=False, ssl_context=None): BaseWSGIServer.__init__(self, host, port, app, handler, passthrough_errors, ssl_context) self.max_children = processes
Example #13
Source File: policy_server.py From ray with Apache License 2.0 | 5 votes |
def __init__(self, external_env, address, port): deprecation_warning( "rllib.utils.PolicyClient", new="rllib.env.PolicyClient") handler = _make_handler(external_env) HTTPServer.__init__(self, (address, port), handler)
Example #14
Source File: serving.py From Financial-Portfolio-Flask with MIT License | 5 votes |
def __init__(self, host, port, app, handler=None, passthrough_errors=False, ssl_context=None, fd=None): if handler is None: handler = WSGIRequestHandler self.address_family = select_ip_version(host, port) if fd is not None: real_sock = socket.fromfd(fd, self.address_family, socket.SOCK_STREAM) port = 0 HTTPServer.__init__(self, (host, int(port)), handler) self.app = app self.passthrough_errors = passthrough_errors self.shutdown_signal = False self.host = host self.port = port # Patch in the original socket. if fd is not None: self.socket.close() self.socket = real_sock self.server_address = self.socket.getsockname() 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() # If we are on Python 2 the return value from socket.fromfd # is an internal socket object but what we need for ssl wrap # is the wrapper around it :( sock = self.socket if PY2 and not isinstance(sock, socket.socket): sock = socket.socket(sock.family, sock.type, sock.proto, sock) self.socket = ssl_context.wrap_socket(sock, server_side=True) self.ssl_context = ssl_context else: self.ssl_context = None
Example #15
Source File: serving.py From Financial-Portfolio-Flask with MIT License | 5 votes |
def __init__(self, protocol): self._protocol = protocol self._certfile = None self._keyfile = None self._password = None
Example #16
Source File: record.py From ethoscope with GNU General Public License v3.0 | 5 votes |
def __init__(self, machine_id, name, version, ethoscope_dir, data=None, *args, **kwargs): # for FPS computation self._last_info_t_stamp = 0 self._last_info_frame_idx = 0 # Metadata self._recorder = None self._machine_id = machine_id self._device_name = name self._video_root_dir = ethoscope_dir self._tmp_dir = tempfile.mkdtemp(prefix="ethoscope_") #todo add 'data' -> how monitor was started to metadata self._info = {"status": "stopped", "time": time.time(), "error": None, "log_file": os.path.join(ethoscope_dir, self._log_file), "dbg_img": os.path.join(ethoscope_dir, self._dbg_img_file), "last_drawn_img": os.path.join(self._tmp_dir, self._tmp_last_img_file), "id": machine_id, "name": name, "version": version, "experimental_info": {} } self._parse_user_options(data) super(ControlThread, self).__init__()
Example #17
Source File: serving.py From planespotter with MIT License | 5 votes |
def __init__(self, rfile): self._rfile = rfile self._done = False self._len = 0
Example #18
Source File: serving.py From pyRevit with GNU General Public License v3.0 | 5 votes |
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
Example #19
Source File: record.py From ethoscope with GNU General Public License v3.0 | 5 votes |
def __init__(self, video_prefix, video_dir, img_path): super(StandardVideoRecorder, self).__init__(video_prefix, video_dir, img_path, width=1280, height=960,fps=25,bitrate=500000)
Example #20
Source File: record.py From ethoscope with GNU General Public License v3.0 | 5 votes |
def __init__(self, video_prefix, video_dir, img_path): super(HDVideoRecorder, self).__init__(video_prefix, video_dir, img_path, width=1920, height=1080,fps=25,bitrate=1000000)
Example #21
Source File: confserver.py From bumper with GNU General Public License v3.0 | 5 votes |
def __init__(self, server_address): Thread.__init__(self) self.server_address = server_address self.handler = RequestHandler self.exit_flag = False
Example #22
Source File: record.py From ethoscope with GNU General Public License v3.0 | 5 votes |
def __init__(self, video_prefix, video_dir, img_path,width=1280, height=960,fps=25,bitrate=200000,stream=False): self._stop_queue = multiprocessing.JoinableQueue(maxsize=1) self._stream = stream self._p = PiCameraProcess(self._stop_queue, video_prefix, video_dir, img_path, width, height,fps, bitrate, stream)
Example #23
Source File: record.py From ethoscope with GNU General Public License v3.0 | 5 votes |
def __init__(self, stop_queue, video_prefix, video_root_dir, img_path, width, height, fps, bitrate, stream=False): self._stop_queue = stop_queue self._img_path = img_path self._resolution = (width, height) self._fps = fps self._bitrate = bitrate self._video_prefix = video_prefix self._video_root_dir = video_root_dir self._stream = stream super(PiCameraProcess, self).__init__()
Example #24
Source File: record.py From ethoscope with GNU General Public License v3.0 | 5 votes |
def __init__(self, camera, *args, **kw): self.camera = camera HTTPServer.__init__(self, *args, **kw)
Example #25
Source File: webhook.py From CPU-Manager-for-Kubernetes with Apache License 2.0 | 5 votes |
def __init__(self, config, handler_class): self.config = config try: HTTPServer.__init__(self, (self.config.address, self.config.port), handler_class) ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) ssl_context.load_cert_chain(self.config.cert, self.config.key) except KeyError as err: logging.error("Error applying server config {}.".format(str(err))) sys.exit(1) self.socket = ssl_context.wrap_socket(self.socket, server_side=True)
Example #26
Source File: webhook.py From CPU-Manager-for-Kubernetes with Apache License 2.0 | 5 votes |
def __init__(self): self.server = {}
Example #27
Source File: confserver.py From bumper with GNU General Public License v3.0 | 5 votes |
def run(self): try: HTTPServer.__init__(self, self.server_address, self.handler) logging.info('ConfServer: listening on {}:{}'.format(self.server_address[0], self.server_address[1])) while not self.exit_flag: self.handle_request() except Exception as e: logging.error('ConfServer: {}'.format(e))
Example #28
Source File: test_logging.py From ironpython3 with Apache License 2.0 | 5 votes |
def __init__(self, *args, **kwargs): super(RecordingHandler, self).__init__(*args, **kwargs) self.records = []
Example #29
Source File: serving.py From recruit with Apache License 2.0 | 5 votes |
def __init__(self, rfile): self._rfile = rfile self._done = False self._len = 0
Example #30
Source File: serving.py From Financial-Portfolio-Flask with MIT License | 5 votes |
def __init__(self, host, port, app, processes=40, handler=None, passthrough_errors=False, ssl_context=None, fd=None): BaseWSGIServer.__init__(self, host, port, app, handler, passthrough_errors, ssl_context, fd) self.max_children = processes