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