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


Python SimpleHTTPServer.SimpleHTTPRequestHandler方法代码示例

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


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

示例1: __init__

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
def __init__(self,request, client_address, server):
            self.server = server
            self.protocol_version = 'HTTP/1.1'
            self.challengeMessage = None
            self.target = None
            self.client = None
            self.machineAccount = None
            self.machineHashes = None
            self.domainIp = None
            self.authUser = None
            if self.server.config.mode != 'REDIRECT':
                if self.server.config.target is not None:
                    self.target = self.server.config.target.get_target(client_address[0],self.server.config.randomtargets)
                    logging.info("HTTPD: Received connection from %s, attacking target %s" % (client_address[0] ,self.target[1]))
                else:
                    self.target = self.client_address[0]
                    logging.info("HTTPD: Received connection from %s, attacking target %s" % (client_address[0] ,client_address[0]))
            SimpleHTTPServer.SimpleHTTPRequestHandler.__init__(self,request, client_address, server) 
开发者ID:joxeankoret,项目名称:CVE-2017-7494,代码行数:20,代码来源:httprelayserver.py

示例2: serve

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
def serve(port=PORT):
    '''Serves test XML files over HTTP'''
    
    # Make sure we serve from the tests' XML directory
    os.chdir(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                          'xml'))

    Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
    
    class TestServer(SocketServer.TCPServer):
        allow_reuse_address = True
    
    httpd = TestServer(("", PORT), Handler)
    
    print 'Serving test HTTP server at port', PORT

    httpd_thread = Thread(target=httpd.serve_forever)
    httpd_thread.setDaemon(True)
    httpd_thread.start() 
开发者ID:italia,项目名称:daf-recipes,代码行数:21,代码来源:xml_file_server.py

示例3: call

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
def call(self, input):
        """
        Simple implementation to serve the build directory.
        """

        try:
            dirname, filename = os.path.split(input)
            if dirname:
                os.chdir(dirname)
            httpd = HTTPServer(('127.0.0.1', 8000), SimpleHTTPRequestHandler)
            sa = httpd.socket.getsockname()
            url = "http://" + sa[0] + ":" + str(sa[1]) + "/" + filename
            if self.open_in_browser:
                webbrowser.open(url, new=2)
            print("Serving your slides on " + url)
            print("Use Control-C to stop this server.")
            httpd.serve_forever()
        except KeyboardInterrupt:
            print("The server is shut down.") 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:21,代码来源:serve.py

示例4: __init__

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
def __init__(self,request, client_address, server):
            self.server = server
            self.protocol_version = 'HTTP/1.1'
            self.challengeMessage = None
            self.target = None
            self.client = None
            self.machineAccount = None
            self.machineHashes = None
            self.domainIp = None
            self.authUser = None
            if self.server.config.mode != 'REDIRECT':
                if self.server.config.target is None:
                    # Reflection mode, defaults to SMB at the target, for now
                    self.server.config.target = TargetsProcessor(singletarget = 'SMB://%s:445/' % client_address[0])
                self.target = self.server.config.target.get_target(client_address[0],self.server.config.randomtargets)
                logging.info("HTTPD: Received connection from %s, attacking target %s" % (client_address[0] ,self.target[1]))
            try:
                SimpleHTTPServer.SimpleHTTPRequestHandler.__init__(self,request, client_address, server)
            except Exception, e:
                logging.error(str(e)) 
开发者ID:eth0izzle,项目名称:cracke-dit,代码行数:22,代码来源:httprelayserver.py

示例5: do_POST

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
def do_POST(self):
        post_request = []
        printt(3, "%s - sent POST request." %self.address_string())
       	form = cgi.FieldStorage(self.rfile,
            headers=self.headers,
            environ={'REQUEST_METHOD':'POST',
                     'CONTENT_TYPE':self.headers['Content-Type'],})
        try:
            from core.shell import url
            logger = open("%s.log" %url.replace("https://", "").replace("http://", "").split("/")[0], "w+")
            logger.write("## Data for %s\n\n" %url)
            for tag in form.list:
                tmp = str(tag).split("(")[1]
                key,value = tmp.replace(")", "").replace("\'", "").replace(",", "").split()
                post_request.append("%s %s" %(key,value))
                printt(2, "%s => %s" %(key,value))
                logger.write("%s => %s\n" %(key,value))
            logger.close()
            from core.shell import action_url
            create_post(url,action_url, post_request)
            SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
        except socerr as e:
            printt(3, "Something wrong: (%s) igonring ..." %str(e))
        except Exception as e:
            printt(3, "Something wrong: (%s) igonring ..." %str(e)) 
开发者ID:samyoyo,项目名称:weeman,代码行数:27,代码来源:httpd.py

示例6: do_POST

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
def do_POST(self):
        """ Store the result in a file, shut down the serve and
        then continue the script """
        form = cgi.FieldStorage(
            fp=self.rfile,
            headers=self.headers,
            environ={'REQUEST_METHOD':'POST',
                     'CONTENT_TYPE':self.headers['Content-Type'],
                     })
        for item in form.list:
            print item.name
            if item.name == "obj_json":
                save_string_in_tmp_folder(
                    data=item.value, 
                    filename="obj.json")
                break

        shutdown_server(server_target=self.server)
        SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) 
开发者ID:Quantipy,项目名称:quantipy,代码行数:21,代码来源:handlers.py

示例7: test

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
def test(HandlerClass = SimpleHTTPRequestHandler,
            ServerClass = ThreadedServer, 
            protocol="HTTP/1.0"):
        '''
        Test: Run an HTTP server on port 8002
        '''

        port = 8002
        server_address = ('', port)

        HandlerClass.protocol_version = protocol
        httpd = ServerClass(server_address, HandlerClass)

        sa = httpd.socket.getsockname()
        print "Serving HTTP on", sa[0], "port", sa[1], "..."
        httpd.serve_forever() 
开发者ID:ActiveState,项目名称:code,代码行数:18,代码来源:recipe-574454.py

示例8: __init__

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
def __init__(self,request, client_address, server):
            self.server = server
            self.protocol_version = 'HTTP/1.1'
            self.challengeMessage = None
            self.target = None
            self.client = None
            self.machineAccount = None
            self.machineHashes = None
            self.domainIp = None
            self.authUser = None
            self.wpad = 'function FindProxyForURL(url, host){if ((host == "localhost") || shExpMatch(host, "localhost.*") ||(host == "127.0.0.1")) return "DIRECT"; if (dnsDomainIs(host, "%s")) return "DIRECT"; return "PROXY %s:80; DIRECT";} '
            if self.server.config.mode != 'REDIRECT':
                if self.server.config.target is None:
                    # Reflection mode, defaults to SMB at the target, for now
                    self.server.config.target = TargetsProcessor(singleTarget='SMB://%s:445/' % client_address[0])
                self.target = self.server.config.target.getTarget(self.server.config.randomtargets)
                LOG.info("HTTPD: Received connection from %s, attacking target %s://%s" % (client_address[0] ,self.target.scheme, self.target.netloc))
            try:
                SimpleHTTPServer.SimpleHTTPRequestHandler.__init__(self,request, client_address, server)
            except Exception, e:
                LOG.error(str(e))
                LOG.debug(traceback.format_exc()) 
开发者ID:Ridter,项目名称:Exchange2domain,代码行数:24,代码来源:httprelayserver.py

示例9: webserver_port

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
def webserver_port(tmpdir, request):
    """Serve fragments via HTTP on a random port (return the port number)."""
    handler = SimpleHTTPServer.SimpleHTTPRequestHandler
    httpd = SocketServer.TCPServer(('', 0), handler)
    port = httpd.socket.getsockname()[1]
    # Create some files to serve.
    webroot = tmpdir.join('webroot')
    webroot.mkdir()
    webroot.join('inc.txt').write('Web \u1234'.encode('utf-8'), mode='wb')
    webroot.join('metainc.txt').write(
        '%include http://localhost:{}/inc.txt%'.format(port))
    # Change to this directory and start the webserver in another thread.
    os.chdir(str(webroot))
    thread = threading.Thread(target=httpd.serve_forever)
    thread.setDaemon(True)
    thread.start()
    # Make sure we shut it down at the end of the test.
    request.addfinalizer(httpd.shutdown)
    return port 
开发者ID:adblockplus,项目名称:python-abp,代码行数:21,代码来源:test_render_script.py

示例10: main

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
def main():
    Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
    Handler.extensions_map['.pac'] = 'application/x-ns-proxy-autoconfig'

    try:
        port = int(sys.argv[1])
    except:
        port = DEFAULT_PORT

    print "Serving at port %s/tcp ..." % port

    httpd = SocketServer.TCPServer(("", port), Handler)
    httpd.serve_forever()

##############
# Enry Point #
############## 
开发者ID:SafeBreach-Labs,项目名称:pacdoor,代码行数:19,代码来源:pac_websrv.py

示例11: getRequester

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
def getRequester():
    accessed = {}

    class SmallFileHttpRequestor(SimpleHTTPRequestHandler):
        # shut up!
        def log_message(self, *args, **kw):
            pass

        def do_GET(self):
            if self.path in accessed:
                accessed[self.path] += 1
            else:
                accessed[self.path] = 1
            response = '%s:%d\n' %(self.path, accessed[self.path])
            if '404' in self.path:
                self.send_response(404)
            else:
                self.send_response(200)
            self.send_header("Content-type", "text/unknown")
            self.send_header("Content-Length", len(response))
            self.end_headers()
            self.wfile.write(response)
    return SmallFileHttpRequestor 
开发者ID:sassoftware,项目名称:conary,代码行数:25,代码来源:lookasidetest.py

示例12: cookieRequester

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
def cookieRequester():
    class CookieFileHttpRequestor(SimpleHTTPRequestHandler):
        # shut up!
        def log_message(self, *args, **kw):
            pass

        def do_GET(self):
            if 'Cookie' not in self.headers:
                self.send_response(302)
                baseUrl = 'http://%s:%s/' %(self.server.server_name,
                                            self.server.server_port)
                self.send_header('Set-Cookie', 'session=1;')
                self.send_header('Location', baseUrl + self.path)
                self.end_headers()
            else:
                self.send_response(200)
                response = 'Hello, world!\n'
                self.send_header('Content-type', 'text/unknown')
                self.send_header('Content-Length', len(response))
                self.end_headers()
                self.wfile.write(response)
    return CookieFileHttpRequestor 
开发者ID:sassoftware,项目名称:conary,代码行数:24,代码来源:lookasidetest.py

示例13: send_head

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
def send_head(self):
        path = self.translate_path(self.path)
        if sys.platform == 'win32':
            if os.path.split(path)[1].lower().split('.')[0] in reserved_names:
                self.send_error(404, "File not found")
                return
        if os.path.isdir(path):
            if not self.path.endswith('/'):
                self.send_response(302)
                x = '<META HTTP-EQUIV="refresh" CONTENT="0;URL=%s/">'%self.path
                self.send_header("Content-Location", self.path + '/')
                self.send_header("Content-Length", len(x))
                self.end_headers()
                self.wfile.write(x)
                return None
        return SimpleHTTPServer.SimpleHTTPRequestHandler.send_head(self) 
开发者ID:thehyperadvisor,项目名称:cldstk-deploy,代码行数:18,代码来源:SimpleAsyncHTTPServer.py

示例14: translate_path

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
def translate_path(self, path):
        """Translate a /-separated PATH to the local filename syntax.

        Components that mean special things to the local file system
        (e.g. drive or directory names) are ignored.  (XXX They should
        probably be diagnosed.)

        """
        # stolen from SimpleHTTPServer.SimpleHTTPRequestHandler
        # but changed to handle files from a defined basepath instead
        # of os.getcwd()
        path = posixpath.normpath(urllib.unquote(path))
        words = path.split('/')
        words = filter(None, words)
        path = self.server.basepath
        for word in words:
            drive, word = os.path.splitdrive(word)
            head, word = os.path.split(word)
            if word in (os.curdir, os.pardir): continue
            path = os.path.join(path, word)
        return path 
开发者ID:EventGhost,项目名称:EventGhost,代码行数:23,代码来源:__init__.py

示例15: run

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import SimpleHTTPRequestHandler [as 别名]
def run(user, port=4242):
    """
    Build a temporary directory with a visualization and serve it over HTTP.

    Examples
    --------

        >>> bandicoot.visualization.run(U)
        Successfully exported the visualization to /tmp/tmpsIyncS
        Serving bandicoot visualization at http://0.0.0.0:4242
    """
    owd = os.getcwd()
    dir = export(user)
    os.chdir(dir)

    Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
    try:
        httpd = SocketServer.TCPServer(("", port), Handler)
        print("Serving bandicoot visualization at http://0.0.0.0:%i" % port)
        httpd.serve_forever()
    except KeyboardInterrupt:
        print("^C received, shutting down the web server")
        httpd.server_close()
    finally:
        os.chdir(owd) 
开发者ID:computationalprivacy,项目名称:bandicoot,代码行数:27,代码来源:visualization.py


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