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


Python SimpleHTTPRequestHandler.do_GET方法代码示例

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


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

示例1: do_GET

# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import do_GET [as 别名]
    def do_GET(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_GET(self)

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

示例2: do_GET

# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import do_GET [as 别名]
 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,代码行数:9,代码来源:server.py

示例3: do_GET

# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import do_GET [as 别名]
    def do_GET(self):
        params = urlparse(self.path)

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

示例4: do_GET

# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import do_GET [as 别名]
 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,代码行数:10,代码来源:server.py

示例5: do_GET

# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import do_GET [as 别名]
 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,代码行数:10,代码来源:asa_server.py

示例6: do_GET

# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import do_GET [as 别名]
 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,代码行数:10,代码来源:netserver.py

示例7: do_GET

# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import do_GET [as 别名]
 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,代码行数:10,代码来源:standalone.py

示例8: do_GET

# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import do_GET [as 别名]
 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,代码行数:10,代码来源:vaw_websocket.py

示例9: do_POST

# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import do_GET [as 别名]
 def do_POST(self):
     """Handle POST request. If web server is enabled,
     SimpleHTTPRequestHandler.do_GET will be called."""
     if self.only_upgrade:
         self.send_error(405, "Method Not Allowed")
     else:
         # SimpleHTTPRequestHandler has no do_POST function, but we don't need
         # anything special, just to respond in the same way as the GET
         SimpleHTTPRequestHandler.do_GET(self)
开发者ID:joshiggins,项目名称:websockify,代码行数:11,代码来源:websocket.py

示例10: do_GET

# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import do_GET [as 别名]
 def do_GET(self, method='GET'):
     #copy all data into a place we can see later.
     self.wfile = FileWrapper(self.wfile)
     #give the actual work of handling the request to SimpleHTTPRequestHandler
     SimpleHTTPRequestHandler.do_GET(self)
     #by this time, the shim file object we created previously is
     #full of the response data and is ready to display.
     print('')
     print(self._heading('HTTP Response'))
     print(self.wfile)
开发者ID:haiqiong,项目名称:Python-web-app,代码行数:12,代码来源:webserver-simple2.py

示例11: do_GET

# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import do_GET [as 别名]
    def do_GET(s):
        print(s.path)
        if s.path.lower().endswith(".stl"):
            filename = "." + s.path
            if os.path.exists(filename):
                stream_mesh_file(s, filename)
                return

        # if we get here, we didn't get an stl file to stream
        # call the parent's get
        C_simple_handler.do_GET(s)
开发者ID:hugomatic,项目名称:morphogen,代码行数:13,代码来源:httpd.py

示例12: do_GET

# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import do_GET [as 别名]
 def do_GET( self ):
     urlParams = urlparse(self.path)
     if os.access( '.' + os.sep + urlParams.path, os.R_OK ):
         SimpleHTTPRequestHandler.do_GET(self);
     else:
         self.send_response(200)
         self.send_header( 'Content-type', 'text/html' )
         self.end_headers()
         with open('index.html', 'r') as f:
             html = f.read()
         self.wfile.write( html.encode() )
开发者ID:xsistens,项目名称:scalajs-facade-bug,代码行数:13,代码来源:server.py

示例13: do_GET

# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import do_GET [as 别名]
 def do_GET(self):
     pr = urllib.parse.urlparse(self.path)
     if pr.path == '/v':
         params = urllib.parse.parse_qs(pr.query)
         self.send_response(200)
         self.send_header("Content-type", "text/html")
         self.end_headers()
         self.wfile.write(self.getPost(pr.path, params['p'][0]).encode())
         self.wfile.flush()
     else:
         SimpleHTTPRequestHandler.do_GET(self)
开发者ID:programmingforliving,项目名称:pfl-tools,代码行数:13,代码来源:OfflineBlogServer.py

示例14: do_GET

# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import do_GET [as 别名]
 def do_GET(self):
     with open('index.html') as index_file_handle:
         url_params = urlparse.urlparse(self.path)
         if os.access('.{}{}'.format(
             os.sep, url_params.path), os.R_OK
         ):
             SimpleHTTPRequestHandler.do_GET(self)
         else:
             self.send_response(200)
             self.send_header('Content-type', 'text/html')
             self.end_headers()
             self.wfile.write(index_file_handle.read().encode('utf8'))
开发者ID:hitchtest,项目名称:hitchnode,代码行数:14,代码来源:static_serve.py

示例15: do_GET

# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import do_GET [as 别名]
 def do_GET(self):
     if self.path not in ('/', '/termlib.js'):
         self.send_response(404)
         self.send_header('Content-type', 'text/plain')
         self.end_headers()
         self.wfile.write(b'404')
         return
     os.chdir(os.path.dirname(__file__))
     if PY3:
         super().do_GET()
     else:
         SimpleHTTPRequestHandler.do_GET(self)
     os.chdir(cwd)
开发者ID:krotkiewicz,项目名称:simplewebshell,代码行数:15,代码来源:__init__.py


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