當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。