{"html_url": "https://github.com/simonw/datasette/issues/873#issuecomment-675610275", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/873", "id": 675610275, "node_id": "MDEyOklzc3VlQ29tbWVudDY3NTYxMDI3NQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-18T17:24:05Z", "updated_at": "2020-08-18T17:26:10Z", "author_association": "OWNER", "body": "Maybe I can do this with ASGI after all. Here's the output of `/-/asgi-scope` with `datasette-debug-asgi` installed:\r\n```\r\n{'asgi': {'spec_version': '2.1', 'version': '3.0'},\r\n 'client': ('127.0.0.1', 62035),\r\n 'headers': [(b'host', b'127.0.0.1:62029'),\r\n (b'user-agent',\r\n b'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:79.0) Gecko'\r\n b'/20100101 Firefox/79.0'),\r\n (b'accept',\r\n b'text/html,application/xhtml+xml,application/xml;q=0.9,image/'\r\n b'webp,*/*;q=0.8'),\r\n (b'accept-language', b'en-US,en;q=0.5'),\r\n (b'accept-encoding', b'gzip, deflate'),\r\n (b'dnt', b'1'),\r\n (b'connection', b'keep-alive'),\r\n (b'upgrade-insecure-requests', b'1'),\r\n (b'cache-control', b'max-age=0')],\r\n 'http_version': '1.1',\r\n 'method': 'GET',\r\n 'path': '/-/asgi-scope',\r\n 'query_string': b'',\r\n 'raw_path': b'/-/asgi-scope',\r\n 'root_path': '',\r\n 'scheme': 'http',\r\n 'server': ('127.0.0.1', 62029),\r\n 'type': 'http'}\r\n```\r\nThat `'server': ('127.0.0.1', 62029)` bit has the correct port. Question is, can I access that programmatically on server startup?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 647095487, "label": "\"datasette -p 0 --root\" gives the wrong URL"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/873#issuecomment-675609109", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/873", "id": 675609109, "node_id": "MDEyOklzc3VlQ29tbWVudDY3NTYwOTEwOQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-18T17:21:51Z", "updated_at": "2020-08-18T17:21:51Z", "author_association": "OWNER", "body": "Asked about this on the encode gitter here: https://gitter.im/encode/community?at=5f3c0dcaa8c17801765940c0", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 647095487, "label": "\"datasette -p 0 --root\" gives the wrong URL"}, "performed_via_github_app": null}