mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Optional path parameters for custom pages, closes #944
This commit is contained in:
parent
ea340cf320
commit
cc77fcd133
3 changed files with 72 additions and 3 deletions
|
|
@ -25,6 +25,9 @@ def custom_pages_client(tmp_path_factory):
|
|||
(pages_dir / "redirect2.html").write_text(
|
||||
'{{ custom_redirect("/example", 301) }}', "utf-8"
|
||||
)
|
||||
(pages_dir / "route_{name}.html").write_text(
|
||||
"<p>Hello from {{ name }}</p>", "utf-8"
|
||||
)
|
||||
nested_dir = pages_dir / "nested"
|
||||
nested_dir.mkdir()
|
||||
(nested_dir / "nest.html").write_text("Nest!", "utf-8")
|
||||
|
|
@ -83,3 +86,9 @@ def test_redirect2(custom_pages_client):
|
|||
response = custom_pages_client.get("/redirect2", allow_redirects=False)
|
||||
assert 301 == response.status
|
||||
assert "/example" == response.headers["Location"]
|
||||
|
||||
|
||||
def test_custom_route_pattern(custom_pages_client):
|
||||
response = custom_pages_client.get("/route_Sally")
|
||||
assert response.status == 200
|
||||
assert response.text == "<p>Hello from Sally</p>"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue