Commit graph

6 commits

Author SHA1 Message Date
alvinttang
300fe125c5 fix: resolve actual port before printing --root URL when -p 0
Closes #873.

When `datasette -p 0 --root` was used, the printed auth-token URL
contained the literal placeholder port 0 instead of the OS-assigned
port that uvicorn would later bind to. Same applied to `--open`.

Fix: when `port == 0` and we need to print/open a URL before the
server starts (because of --root or --open), pre-bind a TCP socket
on (host, 0), read the assigned port via getsockname(), and hand the
bound socket to uvicorn via Server.run(sockets=[...]). uvicorn.run()'s
own `fd=` parameter assumes AF_UNIX so we use the Config/Server API
in this branch only; the existing uvicorn.run() path is unchanged.

Adds a regression test that launches `datasette --memory -p 0 --root`,
parses the printed URL, asserts the port is non-zero, and confirms a
server is actually listening on that port.
2026-04-25 22:30:14 +08:00
Simon Willison
d1d369456a Move HTTPS test to a bash script
See https://github.com/simonw/datasette/issues/1955#issuecomment-1356627931
2022-12-17 18:33:07 -08:00
Simon Willison
de2a106328 Ran Black, refs #1388 2021-07-10 16:46:49 -07:00
Simon Willison
180c7a5328 --uds option for binding to Unix domain socket, closes #1388 2021-07-10 16:37:30 -07:00
Simon Willison
0a7621f96f
Use pytest-xdist to speed up tests (#1290)
* Run tests in CI using pytest-xdist
* Documentation for pytest-xdist

Closes #1289
2021-04-02 20:42:28 -07:00
Simon Willison
9603d893b9 Tests for --ssl-keyfile and --ssl-certfile, refs #1221 2021-02-11 16:53:20 -08:00