本文整理汇总了Python中http.server.SimpleHTTPRequestHandler.handle方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleHTTPRequestHandler.handle方法的具体用法?Python SimpleHTTPRequestHandler.handle怎么用?Python SimpleHTTPRequestHandler.handle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类http.server.SimpleHTTPRequestHandler
的用法示例。
在下文中一共展示了SimpleHTTPRequestHandler.handle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import handle [as 别名]
def handle(self):
# When using run_once, we have a single process, so
# we cannot loop in BaseHTTPRequestHandler.handle; we
# must return and handle new connections
if self.run_once:
self.handle_one_request()
else:
SimpleHTTPRequestHandler.handle(self)
示例2: handle
# 需要导入模块: from http.server import SimpleHTTPRequestHandler [as 别名]
# 或者: from http.server.SimpleHTTPRequestHandler import handle [as 别名]
def handle(self):
"Handle a request and, if anything has changed, rebuild the site."
# overwrite the handle method in SimpleHTTPRequestHandler with this.
# declare most_recent_time global; we'll be changing it later.
global most_recent_time
# figure out the most recent time edited in the source directory
new_recent = most_recent()
# only build the site if the new most recent is more recent than the
# old one, i.e. if one or more of the files has been edited.
if new_recent > most_recent_time:
# update most_recent_time
most_recent_time = new_recent
# Build the site from the source directory
print("Rebuilding your Cytoplasm site...")
site.build()
# Call SimpleHTTPRequestHandler.handle(), so it can do stuff there too.
SimpleHTTPRequestHandler.handle(self)