本文整理汇总了Python中CGIHTTPServer.test方法的典型用法代码示例。如果您正苦于以下问题:Python CGIHTTPServer.test方法的具体用法?Python CGIHTTPServer.test怎么用?Python CGIHTTPServer.test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGIHTTPServer
的用法示例。
在下文中一共展示了CGIHTTPServer.test方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import CGIHTTPServer [as 别名]
# 或者: from CGIHTTPServer import test [as 别名]
def main():
class MyRequestHandler(CGIHTTPServer.CGIHTTPRequestHandler):
def _is_cgi(self):
path = self.path
x = '/cgi-bin/htmlhelp.cgi'
i = len(x)
if path[:i] == x and (not path[i:] or path[i] == '/'):
self.cgi_info = '', path[1:i]
return 1
return 0
CGIHTTPServer.test(MyRequestHandler)
示例2:
# 需要导入模块: import CGIHTTPServer [as 别名]
# 或者: from CGIHTTPServer import test [as 别名]
#!/usr/bin/env python
# _* config: utf-8 _*_
import CGIHTTPServer
CGIHTTPServer.test()
示例3: translate_path
# 需要导入模块: import CGIHTTPServer [as 别名]
# 或者: from CGIHTTPServer import test [as 别名]
break
head, tail = head[:i], head[i:] + tail
temp = self.translate_path(head)
if os.path.isdir(temp):
for index in self.indices:
if os.path.exists(os.path.join(temp, index)):
head = posixpath.join(head, index)
break
ctype = self.guess_type(head)
if ctype in self.actions:
os.environ['REDIRECT_STATUS'] = '200'
head = self.actions[ctype] + head
self.path = head + tail + query
def translate_path(self, path):
path = posixpath.normpath(urllib.unquote(path))
n = len(self.aliases)
for i in range(n):
url, dir = self.aliases[n-i-1]
length = len(url)
if path[:length] == url:
return dir + path[length:]
return ''
if __name__ == '__main__':
CGIHTTPServer.test(PHPHTTPRequestHandler)
示例4: test
# 需要导入模块: import CGIHTTPServer [as 别名]
# 或者: from CGIHTTPServer import test [as 别名]
def test(HandlerClass = PTestCGIHandler,
ServerClass = BaseHTTPServer.HTTPServer):
CGIHTTPServer.test(HandlerClass, ServerClass)
示例5: print
# 需要导入模块: import CGIHTTPServer [as 别名]
# 或者: from CGIHTTPServer import test [as 别名]
# -*- coding: utf-8 -*-
import CGIHTTPServer
if __name__ == '__main__':
print('あああ')
CGIHTTPServer.test();
示例6: test
# 需要导入模块: import CGIHTTPServer [as 别名]
# 或者: from CGIHTTPServer import test [as 别名]
def test(HandlerClass = SymfonyHTTPRequestHandler, ServerClass = HTTPServer):
CGIHTTPServer.test(HandlerClass, ServerClass)
示例7: PyCGIHandler
# 需要导入模块: import CGIHTTPServer [as 别名]
# 或者: from CGIHTTPServer import test [as 别名]
#!/usr/bin/env python
import os
import CGIHTTPServer
class PyCGIHandler(CGIHTTPServer.CGIHTTPRequestHandler):
def is_cgi(self):
splitpath = CGIHTTPServer._url_collapse_path_split(self.path)
script_query = splitpath[1].split("?", 1)
if script_query[0].endswith(".py"):
if splitpath[0].startswith("/"):
# Workaround for some weirdness with how CGIHTTPServer
# computes the SCRIPT_NAME environment variable.
splitpath = list(splitpath)
splitpath[0] = ''
splitpath = tuple(splitpath)
self.cgi_info = splitpath
return True
return False
os.chdir("www")
CGIHTTPServer.test(HandlerClass=PyCGIHandler)