{"html_url": "https://github.com/simonw/datasette/issues/394#issuecomment-451704724", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/394", "id": 451704724, "node_id": "MDEyOklzc3VlQ29tbWVudDQ1MTcwNDcyNA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-01-06T00:32:23Z", "updated_at": "2019-01-06T00:33:44Z", "author_association": "OWNER", "body": "I found a really nice pattern for writing the unit tests for this (though it would look even nicer with a solution to #395)\r\n```python\r\n@pytest.mark.parametrize(\"prefix\", [\"/prefix/\", \"https://example.com/\"])\r\n@pytest.mark.parametrize(\"path\", [\r\n \"/\",\r\n \"/fixtures\",\r\n \"/fixtures/compound_three_primary_keys\",\r\n \"/fixtures/compound_three_primary_keys/a,a,a\",\r\n \"/fixtures/paginated_view\",\r\n])\r\ndef test_url_prefix_config(prefix, path):\r\n for client in make_app_client(config={\r\n \"url_prefix\": prefix,\r\n }):\r\n response = client.get(path)\r\n soup = Soup(response.body, \"html.parser\")\r\n for a in soup.findAll(\"a\"):\r\n href = a[\"href\"]\r\n if href not in {\r\n \"https://github.com/simonw/datasette\",\r\n \"https://github.com/simonw/datasette/blob/master/LICENSE\",\r\n \"https://github.com/simonw/datasette/blob/master/tests/fixtures.py\",\r\n }:\r\n assert href.startswith(prefix), (href, a.parent)\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 396212021, "label": "base_url configuration setting"}, "performed_via_github_app": null}
{"html_url": "https://github.com/simonw/datasette/issues/394#issuecomment-602913427", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/394", "id": 602913427, "node_id": "MDEyOklzc3VlQ29tbWVudDYwMjkxMzQyNw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-03-23T23:27:44Z", "updated_at": "2020-03-23T23:27:44Z", "author_association": "OWNER", "body": "Thanks very much @terrycojones - I'll see if I can finish it up from here.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 396212021, "label": "base_url configuration setting"}, "performed_via_github_app": null}
{"html_url": "https://github.com/simonw/datasette/issues/394#issuecomment-602955699", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/394", "id": 602955699, "node_id": "MDEyOklzc3VlQ29tbWVudDYwMjk1NTY5OQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-03-24T01:34:06Z", "updated_at": "2020-03-24T01:34:15Z", "author_association": "OWNER", "body": "I don't think I'll go with the `
View Datasette (Click on the stop button to close the Datasette server)
'))\r\n\r\n # Launch Datasette\r\n with Popen(\r\n [\r\n 'python', '-m', 'datasette', '--',\r\n database,\r\n '--port', str(port),\r\n '--config', f'base_url:{proxy_url}'\r\n ],\r\n stdout=PIPE,\r\n stderr=PIPE,\r\n bufsize=1,\r\n universal_newlines=True\r\n ) as p:\r\n print(p.stdout.readline(), end='')\r\n while True:\r\n try:\r\n line = p.stderr.readline()\r\n if not line:\r\n break\r\n print(line, end='')\r\n exit_code = p.poll()\r\n except KeyboardInterrupt:\r\n p.send_signal(SIGINT)\r\n```\r\n\r\nIdeally, I'd like some extra magic to notify users when they are leaving the closing the notebook tab and make them terminate the running datasette processes. I'll be looking for it.", "reactions": "{\"total_count\": 1, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 1, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 396212021, "label": "base_url configuration setting"}, "performed_via_github_app": null}