mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
More tweaks to root_path handling, refs #1124
This commit is contained in:
parent
6b4c55efea
commit
63efcb35ce
1 changed files with 3 additions and 1 deletions
|
|
@ -282,10 +282,12 @@ async def asgi_send_file(
|
||||||
|
|
||||||
|
|
||||||
def asgi_static(root_path, chunk_size=4096, headers=None, content_type=None):
|
def asgi_static(root_path, chunk_size=4096, headers=None, content_type=None):
|
||||||
|
root_path = Path(root_path)
|
||||||
|
|
||||||
async def inner_static(request, send):
|
async def inner_static(request, send):
|
||||||
path = request.scope["url_route"]["kwargs"]["path"]
|
path = request.scope["url_route"]["kwargs"]["path"]
|
||||||
try:
|
try:
|
||||||
full_path = (Path(root_path) / path).resolve().absolute()
|
full_path = (root_path / path).resolve().absolute()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
await asgi_send_html(send, "404", 404)
|
await asgi_send_html(send, "404", 404)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue