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


Python server.SimpleHTTPRequestHandler类代码示例

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


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

示例1: __init__

 def __init__(self, request, client_address, server):
     self._logger = get_ws_logger(self)
     self.origin = server.origin
     self.port = server.port
     self.permissive = server.permissive
     SimpleHTTPRequestHandler.__init__(self, request,
                                       client_address, server)
开发者ID:sean-m-brennan,项目名称:pysysdevel,代码行数:7,代码来源:pywebsocketserver.py

示例2: do_POST

    def do_POST(self):
        params = urlparse(self.path)

        if params.path in self.handlers:
            self.handlers[params.path](self)
        else:
            SimpleHTTPRequestHandler.do_POST(self)
开发者ID:,项目名称:,代码行数:7,代码来源:

示例3: end_headers

 def end_headers(self):
     self.send_header('Access-Control-Allow-Origin', '*')
     self.send_header('Access-Control-Allow-Headers', 'x-request-timestamp, x-signature, electricitymap-token')
     self.send_header('Cache-Control', 'no-cache, no-store, must-revalidate')
     self.send_header('Pragma', 'no-cache')
     self.send_header('Expires', '0')
     SimpleHTTPRequestHandler.end_headers(self)
开发者ID:corradio,项目名称:electricitymap,代码行数:7,代码来源:server.py

示例4: do_HEAD

 def do_HEAD(self):
     """Serve a HEAD request."""
     content = self._regenerate(self.path)
     if content:
         self._send_regenerated_head(content)
     else:
         SimpleHTTPRequestHandler.do_HEAD(self)
开发者ID:kevinbeaty,项目名称:mvw,代码行数:7,代码来源:server.py

示例5: do_GET

 def do_GET(self):
     if self.path == "/shutdown/":
         self.wfile.write("HTTP/1.1 200 OK\n\nShutting down...".encode())
         self.send_response(200)
         subprocess.Popen(["shutdown", "-h", "now"]).wait()
     else:
         SimpleHTTPRequestHandler.do_GET(self)
开发者ID:michaelsproul,项目名称:remote-shutdown,代码行数:7,代码来源:server.py

示例6: __init__

 def __init__(self, req, addr, only_upgrade=False, file_only=False,
              no_parent=False):
     self.only_upgrade = only_upgrade # only allow upgrades
     self.webroot = os.path.realpath(".")
     self.file_only = file_only
     self.no_parent = no_parent
     SimpleHTTPRequestHandler.__init__(self, req, addr, object())
开发者ID:DirectXMan12,项目名称:websockify,代码行数:7,代码来源:websocket.py

示例7: do_HEAD

    def do_HEAD(self):
        parsed_path = urllib.parse.urlparse(self.path)
        if parsed_path.path.startswith("/echo"):
            message = '\n'.join(
                [
                    'CLIENT VALUES:',
                    'client_address=%s (%s)' % (self.client_address, self.address_string()),
                    'command=%s' % self.command,
                    'path=%s' % self.path,
                    'real path=%s' % parsed_path.path,
                    'query=%s' % parsed_path.query,
                    'request_version=%s' % self.request_version,
                    '',
                    'HEADERS:',
                    '%s' % self.headers,
                ]
            )
            self.send_response(200)
            self.end_headers()
            self.wfile.write(message.encode('utf-8'))
        elif parsed_path.path.startswith("/redirect"):
            self.send_response(301)
            self.send_header('Location', "/echo")
            self.end_headers()
        else:
            SimpleHTTPRequestHandler.do_HEAD(self)

        return
开发者ID:digininja,项目名称:wfuzz,代码行数:28,代码来源:simple_server.py

示例8: log_message

 def log_message(self, format, *args):
     if DEBUG:
         try:
             SimpleHTTPRequestHandler.log_message(self, format, *args)
         except IOError:
             pass
     else:
         return
开发者ID:ericoporto,项目名称:fgmk,代码行数:8,代码来源:game_server.py

示例9: do_GET

 def do_GET(self):
     """Serve a GET request."""
     content = self._regenerate(self.path)
     if content:
         self._send_regenerated_head(content)
         self.wfile.write(content)
     else:
         SimpleHTTPRequestHandler.do_GET(self)
开发者ID:kevinbeaty,项目名称:mvw,代码行数:8,代码来源:server.py

示例10: do_GET

 def do_GET(self):
     """ Handle http requests to serve html/image files only """
     print( self.path, self.translate_path(self.path))
     permitted_extensions = ['.html','.png','.svg','.jpg', '.js']
     if not os.path.splitext(self.path)[1] in permitted_extensions:
         self.send_error(404, 'File Not Found/Allowed')
     else:
         SimpleHTTPRequestHandler.do_GET(self)
开发者ID:gbiddison,项目名称:giles-scratch,代码行数:8,代码来源:netserver.py

示例11: do_GET

 def do_GET(self,*args,**kwds):
   tmp = self.path.split('/')
   # redirect?
   if (len(tmp) == 3) and (tmp[0] == tmp[2]) and tmp[0] == '':
     self.send_response(301)
     self.send_header('Location', self.path + 'html/')
   else:
     SimpleHTTPRequestHandler.do_GET(self,*args,**kwds)
开发者ID:,项目名称:,代码行数:8,代码来源:

示例12: do_GET

 def do_GET(self):
     """Handle GET request. Calls handle_websocket(). If unsuccessful,
     and web server is enabled, SimpleHTTPRequestHandler.do_GET will be called."""
     if not self.handle_websocket():
         if self.only_upgrade:
             self.send_error(405, "Method Not Allowed")
         else:
             SimpleHTTPRequestHandler.do_GET(self)
开发者ID:virer,项目名称:vaw-router,代码行数:8,代码来源:vaw_websocket.py

示例13: do_GET

 def do_GET(self):
     """Serve a GET request."""
     if not self.allow_path():
         self.send_error(403)
     elif self.is_brat():
         self.run_brat_direct()
     else:
         SimpleHTTPRequestHandler.do_GET(self)
开发者ID:a-tsioh,项目名称:brat,代码行数:8,代码来源:standalone.py

示例14: do_GET

 def do_GET(self):
     if self.path == '/+CSCOE+/logon.html':
         self.redirect('/+CSCOE+/logon.html?fcadbadd=1')
         return
     elif self.path.startswith('/+CSCOE+/logon.html?') and 'reason=1' in self.path:
         self.wfile.write(self.send_file('logon_failure').getvalue())
         return
     SimpleHTTPRequestHandler.do_GET(self)
开发者ID:dtag-dev-sec,项目名称:tpotce,代码行数:8,代码来源:asa_server.py

示例15: handle

 def handle(self):
     # When using run_once, we have a single process, so
     # we cannot loop in BaseHTTPRequestHandler.handle; we
     # must return and handle new connections
     if self.run_once:
         self.handle_one_request()
     else:
         SimpleHTTPRequestHandler.handle(self)
开发者ID:virer,项目名称:vaw-router,代码行数:8,代码来源:vaw_websocket.py


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