本文整理匯總了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)