本文整理汇总了Python中tornado.web.Application.server方法的典型用法代码示例。如果您正苦于以下问题:Python Application.server方法的具体用法?Python Application.server怎么用?Python Application.server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.web.Application
的用法示例。
在下文中一共展示了Application.server方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_server
# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import server [as 别名]
def start_server(app: web.Application = None, port: int = None,
browser: str = None, address: str = None,
check_time: Optional[int] = 500,
**kwargs) -> HTTPServer:
"""Start server with ``app`` on ``localhost:port``.
If port is not specified, use command line option of ``--port``.
If ``browser`` is not specified, do not open the page. When ``browser`` is
specified, open the page with the specified browser. The specified browser
name is not registered in ``webbrowser`` module, or, for example it is just
``True``, use system's default browser to open the page.
"""
app = app or get_app()
port = port if port is not None else config.port
address = address if address is not None else config.address
server = app.listen(port, address=address)
app.server = server
server.address = address
for sock in server._sockets.values():
if sock.family == socket.AF_INET:
server.port = sock.getsockname()[1]
break
return server