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


Python server.BaseHTTPRequestHandler类代码示例

本文整理汇总了Python中http.server.BaseHTTPRequestHandler的典型用法代码示例。如果您正苦于以下问题:Python BaseHTTPRequestHandler类的具体用法?Python BaseHTTPRequestHandler怎么用?Python BaseHTTPRequestHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: send_response

 def send_response(self, code: Union[int, HTTPStatus], message=None):
     """Fill in HTTP status message if not set."""
     if message is None:
         if isinstance(code, HTTPStatus):
             message = code.phrase
             code = code.value
     BaseHTTPRequestHandler.send_response(self, code=code, message=message)
开发者ID:berkmancenter,项目名称:mediacloud,代码行数:7,代码来源:hash_server.py

示例2: __init__

 def __init__(self, *args, **kwargs):
     from django.conf import settings
     self.admin_media_prefix = settings.ADMIN_MEDIA_PREFIX
     # We set self.path to avoid crashes in log_message() on unsupported
     # requests (like "OPTIONS").
     self.path = ''
     BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
开发者ID:gitdlam,项目名称:geraldo,代码行数:7,代码来源:basehttp.py

示例3: finish

 def finish(self):
     """make python2 BaseHTTPRequestHandler happy"""
     try:
         BaseHTTPRequestHandler.finish(self)
     except (IOError, OSError) as e:
         if e[0] not in (errno.ECONNABORTED, errno.ECONNRESET, errno.EPIPE):
             raise
开发者ID:ohyeah521,项目名称:rproxy,代码行数:7,代码来源:rproxy.py

示例4: __init__

 def __init__(self, *args, **kwargs):
     from google.appengine._internal.django.conf import settings
     self.admin_media_prefix = settings.ADMIN_MEDIA_PREFIX
     # We set self.path to avoid crashes in log_message() on unsupported
     # requests (like "OPTIONS").
     self.path = ''
     self.style = color_style()
     BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
开发者ID:zenlambda,项目名称:appengine-python3,代码行数:8,代码来源:basehttp.py

示例5: __init__

 def __init__(self, request, client_address, origin):
   self.origin = origin
   #if __name__ != '__main__':
   #  self.origin.log('postman initializing as plugin..', 2)
   #else:
   #  self.origin.log('postman initializing as standalone application..', 2)
   # ^ works
   BaseHTTPRequestHandler.__init__(self, request, client_address, origin)
开发者ID:majestrate,项目名称:SRNd,代码行数:8,代码来源:postman.py

示例6: __init__

 def __init__(self, request, client_address, server):
     '''
     :param request: the request from the client
     :param client_address: client address
     :param server: HTTP server
     '''
     BaseHTTPRequestHandler.__init__(
         self, request, client_address, server)
     self.dataman = None
开发者ID:dark-lbp,项目名称:kitty,代码行数:9,代码来源:web.py

示例7: __init__

    def __init__(self, request, client_address, server):
        try:
            mimetypes.init()
            self.DebugMode = False

            BaseHTTPRequestHandler.__init__(self, request, client_address, server)

        except:
            ReportException()
开发者ID:CarlosOnline,项目名称:Python,代码行数:9,代码来源:WebServer.py

示例8: test

def test(handler):
    sess_id = handler.query.split('=',1)[1]
    handler.send_response(200)
    handler.send_header("Content-type", "text/html")
    msg = "{}={}".format(sess_id, 1000)
    handler.send_header("Content-length", str(len(msg)))
    handler.send_header("Connection", "close")
    handler.end_headers()
    BaseHTTPRequestHandler.end_headers(handler)
    handler.wfile.write("{}!".format(msg))
开发者ID:nycnighthawk,项目名称:ConfigLine,代码行数:10,代码来源:threaded_http_server.py

示例9: __init__

 def __init__(self, *args, **kwargs):
     sock = socket_wrapper.Socket(unix_socket=True)
     sock.make_nonblocking()
     if not sock.connect_unix(os.path.expanduser(PETTYCOIN_SOCKET)):
         logging.error('Could not open socket: {}'.format(PETTYCOIN_SOCKET))
         sys.exit(1)
     self.petty_sock = sock
     self.petty_reader = JsonSocketReader(sock)
     self.html_parser = HTMLParser()
     BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
开发者ID:arhuaco,项目名称:pypettycoin,代码行数:10,代码来源:bad_proxy.py

示例10: __init__

    def __init__(self, http_svc, *args, **kwargs):
        """
        Sets up the request handler (called for each request)

        :param http_svc: The associated HTTP service
        """
        self._service = http_svc

        # This calls the do_* methods
        BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
开发者ID:ahmadshahwan,项目名称:cohorte-runtime,代码行数:10,代码来源:basic.py

示例11: __init__

 def __init__(self, request, client, server):
     request.settimeout(60.)
     try:
         BaseHTTPRequestHandler.__init__(self, request, client, server)
     except OSError as e:
         if server.debug:
             logger.exception("OSError in http request")
         else:
             logger.error("%s", e)
     except Exception:
         logger.exception("Unhandle Error")
开发者ID:flux3dp,项目名称:fluxghost,代码行数:11,代码来源:http_handler.py

示例12: __init__

    def __init__(self, http_svc, *args, **kwargs):
        """
        Constructor
        
        :param http_svc: The associated HTTP service instance
        """
        # Store the reference to the service
        self.service = http_svc

        # Call the parent constructor
        BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
开发者ID:Netcondut,项目名称:ipopo,代码行数:11,代码来源:http_svc.py

示例13: log_message

 def log_message(self, *args, **kwargs):
     if self.command == 'POST':
         sys.stderr.write('{addr} - - [{datetime}] "POST {path} {req_ver}" {statuscode} {data}\n'.format(
             addr=self.address_string(),
             datetime=self.log_date_time_string(),
             path=self.path,
             req_ver=self.request_version,
             statuscode=args[2],
             data=self.POST_data.decode(),
             ))
     else:
         BaseHTTPRequestHandler.log_message(self, *args, **kwargs)
开发者ID:siikamiika,项目名称:mpv-remote,代码行数:12,代码来源:server.py

示例14: send_response

 def send_response(self, mesg, code=200, headers=None):
     'Wraps sending a response down'
     if not headers:
         headers = {}
     if 'Content-Type' not in headers:
         headers['Content-Type'] = 'text/html'
     BaseHTTPRequestHandler.send_response(self, code)
     self.send_header('Content-Length', len(mesg))
     if headers:
         for k, v in headers.items():
             self.send_header(k, v)
     self.end_headers()
     self.wfile.write(mesg)
开发者ID:Ecostack,项目名称:python-impact,代码行数:13,代码来源:py3_server.py

示例15: handle_one_request

    def handle_one_request(self):
        """Extended request handler

        This is where WebSocketRequestHandler redirects requests to the
        new methods. Any sub-classes must call this method in order for
        the calls to function.
        """
        self._real_do_GET = self.do_GET
        self.do_GET = self._websocket_do_GET
        try:
            BaseHTTPRequestHandler.handle_one_request(self)
        finally:
            self.do_GET = self._real_do_GET
开发者ID:michalsrb,项目名称:websockify,代码行数:13,代码来源:websocketserver.py


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