当前位置: 首页>>代码示例>>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方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: do_GET

# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import do_GET [as 别名]
def do_GET(self):
        # Check For URL Stream "http://IPADDRESS/Notify?"
            
        if "/Notify?" in self.path:
            self._set_headers()
            preurl, notification = self.path.split("?")

            # Add some error handling for chrome looping
            redir = "<html><head><meta http-equiv='refresh' content='0;url=.\' /></head><body><h1>Notification Sent! <br>"+notification+"</h1></body></html>"
            print(redir)

            self.wfile.write(redir.encode())
            self.notify(str(notification))
            return
        
        elif "/HelloWorld" in self.path:
            self._set_headers()
            print("Hello World Test")
            self.notify("Hello+World")
            return
            
        else:
            SimpleHTTPRequestHandler.do_GET(self)
   
    # POST is for submitting data 
开发者ID:GhostBassist,项目名称:GooglePyNotify,代码行数:27,代码来源:GooglePyNotify.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.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 http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.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 http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import do_GET [as 别名]
def do_GET(self):
    if self.path == '/ip':
      self.send_response(200)
      self.send_header('Content-type', 'text/html')
      self.end_headers()
      self.wfile.write('ip adresiniz %s' % self.client_address[0])
      return
    else:
      return SimpleHTTPRequestHandler.do_GET(self) 
开发者ID:milisarge,项目名称:malfs-milis,代码行数:11,代码来源:yps_baslat6.py

示例5: do_GET

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

示例6: 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:xmendez,项目名称:wfuzz,代码行数:30,代码来源:simple_server.py

示例7: do_GET

# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.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:
            SimpleHTTPRequestHandler.do_GET(self) 
开发者ID:PyOCL,项目名称:OpenCLGA,代码行数:12,代码来源:HTTPWebSocketsHandler.py

示例8: do_POST

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


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