def start_server(app: web.Application = None, port: int = None,
address: str = None, **kwargs: Any) -> HTTPServer:
"""Start server with ``app`` on ``localhost:port``.
If port is not specified, use command line option of ``--port``.
"""
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_config['address'] = address
for sock in server._sockets.values():
if sock.family == socket.AF_INET:
server_config['port'] = sock.getsockname()[1]
break
return server
评论列表
文章目录