本文整理汇总了Python中http.server.HTTPServer.serve_forever方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPServer.serve_forever方法的具体用法?Python HTTPServer.serve_forever怎么用?Python HTTPServer.serve_forever使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类http.server.HTTPServer
的用法示例。
在下文中一共展示了HTTPServer.serve_forever方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: serve_forever
# 需要导入模块: from http.server import HTTPServer [as 别名]
# 或者: from http.server.HTTPServer import serve_forever [as 别名]
def serve_forever(self):
self.shutdown_signal = False
try:
if os.environ.get('WERKZEUG_RUN_MAIN') != 'true':
display_hostname = self.host != '*' and self.host or 'localhost'
if ':' in display_hostname:
display_hostname = '[%s]' % display_hostname
quit_msg = '(Press CTRL+C to quit)'
_log('info', ' * Running on %s://%s:%d/ %s',
self.ssl_context is None and 'http' or 'https',
display_hostname, self.port, quit_msg)
HTTPServer.serve_forever(self)
except KeyboardInterrupt:
pass
finally:
self.server_close()
示例2: serve_forever
# 需要导入模块: from http.server import HTTPServer [as 别名]
# 或者: from http.server.HTTPServer import serve_forever [as 别名]
def serve_forever(self):
self.shutdown_signal = False
try:
HTTPServer.serve_forever(self)
except KeyboardInterrupt:
pass
finally:
self.server_close()
示例3: serve_forever
# 需要导入模块: from http.server import HTTPServer [as 别名]
# 或者: from http.server.HTTPServer import serve_forever [as 别名]
def serve_forever(self):
self.shutdown_signal = False
try:
HTTPServer.serve_forever(self)
except KeyboardInterrupt:
pass
示例4: run_forever
# 需要导入模块: from http.server import HTTPServer [as 别名]
# 或者: from http.server.HTTPServer import serve_forever [as 别名]
def run_forever(self, poll_interval=0.5, progress_file=None):
"""Almost synonym for HTTPServer::serve_forever
Handles requests until an explicit shutdown() request. Poll for
shutdown every poll_interval seconds
:param float poll_interval: Time in seconds to poll for shutdown.
:param str progress_file: A JSON file with current status of a
benchmarking experiment.
"""
self.RequestHandlerClass.PROGRESS_FILE = progress_file
HTTPServer.serve_forever(self, poll_interval)