本文整理匯總了Python中BaseHTTPServer.HTTPServer.serve_forever方法的典型用法代碼示例。如果您正苦於以下問題:Python HTTPServer.serve_forever方法的具體用法?Python HTTPServer.serve_forever怎麽用?Python HTTPServer.serve_forever使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類BaseHTTPServer.HTTPServer
的用法示例。
在下文中一共展示了HTTPServer.serve_forever方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: serve_forever
# 需要導入模塊: from BaseHTTPServer import HTTPServer [as 別名]
# 或者: from BaseHTTPServer.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 BaseHTTPServer import HTTPServer [as 別名]
# 或者: from BaseHTTPServer.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 BaseHTTPServer import HTTPServer [as 別名]
# 或者: from BaseHTTPServer.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 BaseHTTPServer import HTTPServer [as 別名]
# 或者: from BaseHTTPServer.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)