本文整理汇总了Python中werkzeug.serving.WSGIRequestHandler方法的典型用法代码示例。如果您正苦于以下问题:Python serving.WSGIRequestHandler方法的具体用法?Python serving.WSGIRequestHandler怎么用?Python serving.WSGIRequestHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类werkzeug.serving
的用法示例。
在下文中一共展示了serving.WSGIRequestHandler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_server
# 需要导入模块: from werkzeug import serving [as 别名]
# 或者: from werkzeug.serving import WSGIRequestHandler [as 别名]
def make_server(host, port, app, logging=True):
if host is None:
raise RuntimeError("host cannot be None")
if port is None:
raise RuntimeError("port cannot be None")
if logging:
request_handler = serving.WSGIRequestHandler
else:
request_handler = QuietRequestHandler
try:
return serving.make_server(
host, port, app, threaded=True, request_handler=request_handler
)
except socket.error as e:
if host:
raise
log.debug(
"error starting server on %s:%s (%s), " "trying IPv6 default host '::'",
host,
port,
e,
)
return serving.make_server("::", port, app, threaded=True)
示例2: run
# 需要导入模块: from werkzeug import serving [as 别名]
# 或者: from werkzeug.serving import WSGIRequestHandler [as 别名]
def run(self, host, port, middleware=None):
"""Werkzeug run implementation.
`middleware` may be provided as a function to handle
requests. It must accept the arguments `(handler, req)` where
`handler` is the TFServeApp request handler and `req` is the
request.
"""
app = self._init_app(middleware)
server = serving.make_server(
host, port, app, threaded=True,
request_handler=serving.WSGIRequestHandler)
server.serve_forever()