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


Python SimpleHTTPServer.test方法代码示例

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


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

示例1: test

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import test [as 别名]
def test(HandlerClass = CGIHTTPRequestHandler,
	 ServerClass = BaseHTTPServer.HTTPServer):
    import sys
    if sys.argv[1:2] == ['-r']:
	db = MyArchive()
	db.regenindices()
	return
    SimpleHTTPServer.test(HandlerClass, ServerClass)
开发者ID:asottile,项目名称:ancient-pythons,代码行数:10,代码来源:CGIHTTPServer.py

示例2: main

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import test [as 别名]
 def main(self):
     log.info("press '^C' to stop server")
     freezerDstPath = self.parent.projectPath / ProjectFinder.BUILD_DIR
     with local.cwd(freezerDstPath):
         sys.argv[1] = self.parent.PORT
         log.info("serve frozen flask from %s at http://localhost:%s",
                  freezerDstPath, self.parent.PORT)
         SimpleHTTPServer.test()
开发者ID:obestwalter,项目名称:sitebuilder,代码行数:10,代码来源:sitebuilder.py

示例3: main

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import test [as 别名]
def main():
    if len(sys.argv) < 2:
        sys.exit("Please supply a directory to serve")
    os.chdir(sys.argv[1])

    # Remove the directory from argv so the HTTP port can still be
    # specified after the directory (read by SimpleHTTPServer.test)
    del sys.argv[1]

    SimpleHTTPServer.test(ServerClass=ThreadingHTTPServer)
开发者ID:AdamIsrael,项目名称:docs,代码行数:12,代码来源:serve.py

示例4: webshare

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import test [as 别名]
def webshare(open_in_browser=False, port=8000):
    if open_in_browser:
        import webbrowser
        def open_in_browser():
            webbrowser.open_new_tab('http://localhost:{0}'.format(port))
        _delay_background(open_in_browser, 0.5)

    # BaseHTTPServer looks at argv[1] for port
    sys.argv = [sys.argv[0], port]
    import SimpleHTTPServer
    try:
        SimpleHTTPServer.test()
    except KeyboardInterrupt:
        print '\nStopping...'
开发者ID:hmarr,项目名称:dotfiles-old,代码行数:16,代码来源:shellcommands.py

示例5: open

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import test [as 别名]
            with open("../suites/%s/%s.json" %(folder_name, suite_name), "w") as fb:
                json.dump(request_data["suite_data"], fb, indent=4) 
                fb.flush()
            os.chdir("../suites/%s" %folder_name)
            assert commands.getstatusoutput("python parse.py %s.json" %suite_name)[0]==0
            zipfb = zipfile.ZipFile("%s.zip" %suite_name, "w")
            zipfb.write("%s.json" %suite_name)
            zipfb.write("%s.robot" %suite_name)
            zipfb.write("variable.py")
            zipfb.write("test_api.py")
            zipfb.close()
            abspath = os.path.realpath(".")
            self.send_response(200)
            self.send_header("Content-Length", len(abspath))
            self.send_header("Connection", "Close")
            self.end_headers()
            self.wfile.write(abspath)
        except:
            self.send_error(500)

    def do_POST(self):
        action = self.distribute_action()
        if not action:
            self.send_error(404)
            return
        else:
            action()

if __name__=="__main__":
    SimpleHTTPServer.test(HandlerClass=CustomHTTPRequestHandler, ServerClass=SimpleHTTPServer.BaseHTTPServer.HTTPServer)
开发者ID:ianxiaohanxu,项目名称:api_test_tool,代码行数:32,代码来源:http_server.py

示例6: dir

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import test [as 别名]
    # change to the kn_apps dir (as this basic HTTP server only references the
    # current directory and below)
    os.chdir(appsDir)

    # start out using the default mod_pubsub server address
    mpsServer = defaultMpsServer

    # read the prologue.js file to get the actual server address
    try:
        prologuePath = os.path.join(appsDir, 'kn_lib', 'prologue.js')
        mpsServer = readPubSubServerAddress (prologuePath)
    except IOError, (errno, strerror):
        sys.stderr.write(
            "Warning, problem accessing %s, (%s): %s\n" % (prologuePath, errno, strerror)
        )
        sys.stderr.flush()
        pass

    # set the PubSub Server name in the replacement list
    for i in range(0,len(replaceStrList)):
        replaceStrList[i] = replaceStrList[i] % mpsServer

    print "\nUsing mod_pubsub server: %s\n" % mpsServer

    SimpleHTTPServer.test(CrossDomainRequestHandler)

if __name__ == "__main__": main(sys.argv)

# End of xdomainserver.py

开发者ID:kragen,项目名称:mod_pubsub,代码行数:31,代码来源:xdomainserver.py

示例7: CORSHandler

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import test [as 别名]
import SimpleHTTPServer

class CORSHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
    def end_headers(self):

        # Chrome won't load fonts without this header
        self.send_header('Access-Control-Allow-Origin', '*')

        SimpleHTTPServer.SimpleHTTPRequestHandler.end_headers(self)

if __name__ == '__main__':
    SimpleHTTPServer.test(HandlerClass=CORSHandler)
开发者ID:rectangletangle,项目名称:dataquest-test-project,代码行数:14,代码来源:srv.py

示例8: NoCacheRequestHandler

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import test [as 别名]
#!/usr/bin/env python

import SimpleHTTPServer


class NoCacheRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):

    def end_headers(self):
        self.send_my_headers()
        SimpleHTTPServer.SimpleHTTPRequestHandler.end_headers(self)

    def send_my_headers(self):
        self.send_header("Cache-Control", "no-cache, no-store, must-revalidate")
        self.send_header("Pragma", "no-cache")
        self.send_header("Expires", "0")


if __name__ == '__main__':
    SimpleHTTPServer.test(HandlerClass=NoCacheRequestHandler)
开发者ID:Stephanie1125,项目名称:Stephanie1125.github.io,代码行数:21,代码来源:nocache_server.py2.py

示例9:

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import test [as 别名]
#!/usr/bin/env python
import SimpleHTTPServer;SimpleHTTPServer.test()
开发者ID:vic,项目名称:ice,代码行数:4,代码来源:serve.py

示例10: test

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import test [as 别名]
def test(HandlerClass = CGIHTTPRequestHandler,
         ServerClass = BaseHTTPServer.HTTPServer):
    SimpleHTTPServer.test(HandlerClass, ServerClass)
开发者ID:Acidburn0zzz,项目名称:kali-2,代码行数:5,代码来源:CGIHTTPServer.py

示例11: translate_path

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import test [as 别名]
  def translate_path(self, path):
    fs_path = SimpleHTTPRequestHandler.translate_path(self, path)
    if self.path.endswith('/'):
      for index in "index.html", "index.htm":
        index = os.path.join(fs_path, index)
        if os.path.exists(index):
          fs_path = index
          break

    if fs_path.endswith('.html'):
      content = ssi.InlineIncludes(fs_path)
      fs_path = self.create_temp_file(fs_path, content)
    return fs_path

  def delete_temp_files(self):
    for temp_file in self.temp_files:
      os.remove(temp_file)

  def create_temp_file(self, original_path, content):
    _, ext = os.path.splitext(original_path)
    fd, path = tempfile.mkstemp(suffix=ext)
    os.write(fd, content)
    os.close(fd)

    self.temp_files.append(path)
    return path


if __name__ == '__main__':
  SimpleHTTPServer.test(HandlerClass=SSIRequestHandler)
开发者ID:burthen,项目名称:dygraphs,代码行数:32,代码来源:ssi_server.py

示例12: main

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import test [as 别名]
def main(argv):
    SimpleHTTPServer.test(EditRequestHandler, SocketServer.TCPServer)
开发者ID:namin,项目名称:ometa-js-projects,代码行数:4,代码来源:EditServer.py

示例13: LocalHTTPRequestHandler

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import test [as 别名]
import mimetypes
import SimpleHTTPServer
import BaseHTTPServer

class LocalHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):

    """SimpleHTTPServer subclass which knows about certain necessary MIME types."""

    SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map.update({
        '.svg': 'image/svg+xml',
        })

if __name__ == '__main__':
    SimpleHTTPServer.test(LocalHTTPRequestHandler, BaseHTTPServer.HTTPServer)
开发者ID:Erls-Corporation,项目名称:siggraph2012course,代码行数:16,代码来源:LocalHTTPServer.py

示例14:

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import test [as 别名]
import webbrowser as browser
import os

import SimpleHTTPServer as s


browser.open('http://localhost:8000/test')
s.test()

开发者ID:danprince,项目名称:hive,代码行数:10,代码来源:run.py

示例15: MyHTTPRequestHandler

# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import test [as 别名]
#!/usr/bin/env python2
import SimpleHTTPServer
import os


class MyHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
	def translate_path(self, path):
		if path.startswith("/~zhaoyich/"):
			path = path[len("/~zhaoyich/"):]
		return SimpleHTTPServer.SimpleHTTPRequestHandler.translate_path(self, path)

if __name__ == "__main__":
	SimpleHTTPServer.test(MyHTTPRequestHandler)
开发者ID:zeroAska,项目名称:smartcar,代码行数:15,代码来源:serve.py


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