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


Python SimpleHTTPRequestHandler.do_GET方法代码示例

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


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

示例1: do_GET

# 需要导入模块: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
# 或者: from SimpleHTTPServer.SimpleHTTPRequestHandler import do_GET [as 别名]
def do_GET(self):
        #self.log_message("HTTPWebSocketsHandler do_GET")
        if self.server.auth and not self.checkAuthentication():
            return
        if self.headers.get("Upgrade", None) and self.headers.get("Upgrade", None).lower().strip() == "websocket":
            self.log_message("do_GET upgrade: headers:\r\n %s" % (str(self.headers),))
            #self.log_message("do_GET upgrade: server %s" % (self.server,))
            #self.log_message("do_GET upgrade: timeout1 %d" % (self.server.socket.gettimeout(),))
            # if self.server.timeout != None:
                # self.log_message("do_GET upgrade: timeout2 %d" % (self.server.timeout,))
            # else:
                # self.log_message("do_GET upgrade: timeout2 None")
        
            #self.server.socket.settimeout(0)
            
            self._handshake()
            #This handler is in websocket mode now.
            #do_GET only returns after client close or socket error.
            self._read_messages()
        else:
            SimpleHTTPRequestHandler.do_GET(self) 
开发者ID:SevenW,项目名称:Plugwise-2-py,代码行数:23,代码来源:HTTPWebSocketsHandler.py

示例2: do_GET

# 需要导入模块: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
# 或者: from SimpleHTTPServer.SimpleHTTPRequestHandler import do_GET [as 别名]
def do_GET(self):
        if self.path.endswith('/plain_text'):
            self.send_response(200)
            self.send_header('Content-type', 'text/plain')
            self.end_headers()
            self.wfile.write(b'This is text/plain')
        elif re.search(r'/set_cookie', self.path):
            self.send_response(200)
            self.send_header('Content-type', 'text/html')
            self.send_header('Set-Cookie', 'monster=1')
            self.end_headers()
            self.wfile.write(b"<html>C is for cookie, it's good enough for me</html>")
        elif not re.search(r'.*\.\w+$', self.path):
            self.send_response(200)
            self.send_header('Content-type', 'text/plain')
            self.end_headers()
        else:
            SimpleHTTPRequestHandler.do_GET(self) 
开发者ID:watir,项目名称:nerodia,代码行数:20,代码来源:webserver.py

示例3: do_GET

# 需要导入模块: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
# 或者: from SimpleHTTPServer.SimpleHTTPRequestHandler import do_GET [as 别名]
def do_GET(self):
        global MAP_OVERRIDE
        path_end = self.path.rsplit('/', 1)[1]
        if path_end in ['FRANCE', 'INNSBRUCK', 'LONDON', 'NEWYORK', 'PARIS', 'RICHMOND', 'WATOPIA', 'YORKSHIRE']:
            MAP_OVERRIDE = path_end
            self.send_response(302)
            self.send_header('Location', 'https://secure.zwift.com/ride')
            self.end_headers()
            return
        if MAP_OVERRIDE and self.path == '/gameassets/MapSchedule_v2.xml':
            self.send_response(200)
            self.send_header('Content-type', 'text/xml')
            self.end_headers()
            output = '<MapSchedule><appointments><appointment map="%s" start="%s"/></appointments><VERSION>1</VERSION></MapSchedule>' % (MAP_OVERRIDE, datetime.now().strftime("%Y-%m-%dT00:01-04"))
            self.wfile.write(output.encode())
            MAP_OVERRIDE = None
            return
        elif self.path == '/gameassets/MapSchedule_v2.xml' and os.path.exists(PROXYPASS_FILE):
            # PROXYPASS_FILE existence indicates we know what we're doing and
            # we can try to obtain the official map schedule. This can only work
            # if we're running on a different machine than the Zwift client.
            try:
                import urllib3
                http = urllib3.PoolManager()
                r = http.request('GET', 'http://cdn.zwift.com/gameassets/MapSchedule_v2.xml')
                self.send_response(200)
                self.send_header('Content-type', 'text/xml')
                self.end_headers()
                self.wfile.write(r.data)
                return
            except:
                pass  # fallthrough to return zoffline version
        if path_end.startswith('saveghost?'):
            self.send_response(200)
            self.end_headers()
            saveGhost(rec.player_id, path_end[10:])
            return

        SimpleHTTPRequestHandler.do_GET(self) 
开发者ID:zoffline,项目名称:zwift-offline,代码行数:41,代码来源:standalone.py

示例4: do_GET

# 需要导入模块: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
# 或者: from SimpleHTTPServer.SimpleHTTPRequestHandler import do_GET [as 别名]
def do_GET(self):
		print "[+] New connection: %s:%d" % (self.client_address[0], self.client_address[1])
		self.index() 
开发者ID:0pc0deFR,项目名称:wordpress-sploit-framework,代码行数:5,代码来源:web_server_builder.py

示例5: index

# 需要导入模块: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
# 或者: from SimpleHTTPServer.SimpleHTTPRequestHandler import do_GET [as 别名]
def index(self):
		global global_method
		if global_method.lower() == "get":
			html_response = '<html><head></head><body>'+self.prepare_request('')+'</body></html>'
		else:
			csrf_name = ''.join(random.choice('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') for i in range(36))
			html_response = '<html><head></head><body onload="document.getElementById(\''+csrf_name+'\').submit()">'+self.prepare_request(csrf_name)+'</body></html>'
		self.send_response(200)
		self.send_header("Content-type", "text/html")
		self.send_header("Content-length", len(html_response))
		self.end_headers()
		self.wfile.write(html_response)
		return SimpleHTTPRequestHandler.do_GET(self) 
开发者ID:0pc0deFR,项目名称:wordpress-sploit-framework,代码行数:15,代码来源:web_server_builder.py

示例6: do_GET

# 需要导入模块: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
# 或者: from SimpleHTTPServer.SimpleHTTPRequestHandler import do_GET [as 别名]
def do_GET(self):
        self.path = 'index.html'
        return SimpleHTTPRequestHandler.do_GET(self) 
开发者ID:djc,项目名称:awmy,代码行数:5,代码来源:serve.py

示例7: do_GET_HTTP

# 需要导入模块: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
# 或者: from SimpleHTTPServer.SimpleHTTPRequestHandler import do_GET [as 别名]
def do_GET_HTTP(self):
        """Override this handler."""
        SimpleHTTPRequestHandler.do_GET(self)
        pass 
开发者ID:alfa-addon,项目名称:addon,代码行数:6,代码来源:HTTPWebSocketsHandler.py

示例8: do_GET

# 需要导入模块: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
# 或者: from SimpleHTTPServer.SimpleHTTPRequestHandler import do_GET [as 别名]
def do_GET(self):
        # if self.server.auth and not self.checkAuthentication():
        #    return
        if self.headers.get("Upgrade", None) == "websocket":
            self._handshake()
            #This handler is in websocket mode now.
            #do_GET only returns after client close or socket error.
            self._read_messages()
        else:
            self.do_GET_HTTP() 
开发者ID:alfa-addon,项目名称:addon,代码行数:12,代码来源:HTTPWebSocketsHandler.py

示例9: do_GET

# 需要导入模块: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
# 或者: from SimpleHTTPServer.SimpleHTTPRequestHandler import do_GET [as 别名]
def do_GET(self):
        url = urlparse(self.path)
        print("url: '%s' url.path: '%s'" % (url, url.path))
        if url.path == "" or url.path == "/":
            self.redirect("/login.html")

        if url.path == "/authenticate":
            self.redirect("/homepage.html")
            return

        if url.path == '/admin/shutdown':
            print("server shutdown has been requested")
            os.kill(os.getpid(), signal.SIGHUP)

        return SimpleHTTPRequestHandler.do_GET(self) 
开发者ID:boakley,项目名称:robotframework-pageobjectlibrary,代码行数:17,代码来源:demoserver.py

示例10: do_POST

# 需要导入模块: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
# 或者: from SimpleHTTPServer.SimpleHTTPRequestHandler import do_GET [as 别名]
def do_POST(self):
        self.do_GET() 
开发者ID:watir,项目名称:nerodia,代码行数:4,代码来源:webserver.py


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