本文整理汇总了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)
示例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()
示例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)
示例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...'
示例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)
示例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
示例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)
示例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)
示例9:
# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import test [as 别名]
#!/usr/bin/env python
import SimpleHTTPServer;SimpleHTTPServer.test()
示例10: test
# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import test [as 别名]
def test(HandlerClass = CGIHTTPRequestHandler,
ServerClass = BaseHTTPServer.HTTPServer):
SimpleHTTPServer.test(HandlerClass, ServerClass)
示例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)
示例12: main
# 需要导入模块: import SimpleHTTPServer [as 别名]
# 或者: from SimpleHTTPServer import test [as 别名]
def main(argv):
SimpleHTTPServer.test(EditRequestHandler, SocketServer.TCPServer)
示例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)
示例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()
示例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)