File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1279,27 +1279,6 @@ the middleware might use :meth:`BaseRequest.clone`.
12791279 for modifying *scheme *, *host * and *remote * attributes according
12801280 to ``Forwarded `` and ``X-Forwarded-* `` HTTP headers.
12811281
1282- Deploying with a dynamic port
1283- -----------------------------
1284-
1285- When deploying aiohttp with zero-configuration networking, it may be useful
1286- to have the server bind to a dynamic port. This can be done by
1287- using the ``0 `` port number. This will cause the OS to assign a
1288- free port to the server. The assigned port can be retrieved
1289- using the :attr: `TCPSite.port ` property after the server has started.
1290-
1291- For example::
1292-
1293- app = web.Application()
1294- runner = web.AppRunner(app)
1295- await runner.setup()
1296- site = web.TCPSite(runner, 'localhost', 0)
1297- await site.start()
1298-
1299- print(f"Server started on port {site.port}")
1300- while True:
1301- await asyncio.sleep(3600) # sleep forever
1302-
13031282CORS support
13041283------------
13051284
Original file line number Diff line number Diff line change @@ -2940,6 +2940,22 @@ application on specific TCP or Unix socket, e.g.::
29402940 This attribute is only guaranteed to be correct after the server has
29412941 been started.
29422942
2943+ When deploying aiohttp with zero-configuration networking, it may be
2944+ useful to have the server bind to a dynamic port. This can be done by
2945+ using the ``0 `` port number, which causes the OS to assign a free port.
2946+ The assigned port can be retrieved using this attribute after the server
2947+ has started::
2948+
2949+ app = web.Application()
2950+ runner = web.AppRunner(app)
2951+ await runner.setup()
2952+ site = web.TCPSite(runner, 'localhost', 0)
2953+ await site.start()
2954+
2955+ print(f"Server started on port {site.port}")
2956+ while True:
2957+ await asyncio.sleep(3600) # sleep forever
2958+
29432959
29442960.. class :: UnixSite(runner, path, *, \
29452961 shutdown_timeout=60.0, ssl_context=None, \
You can’t perform that action at this time.
0 commit comments