kopia lustrzana https://github.com/simonw/datasette
fix RuntimeError related to static headers
rodzic
9d7152da85
commit
eacf20cbff
|
@ -309,10 +309,14 @@ 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)
|
root_path = Path(root_path)
|
||||||
headers = headers or {}
|
static_headers = {}
|
||||||
|
|
||||||
|
if headers:
|
||||||
|
static_headers = headers.copy()
|
||||||
|
|
||||||
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"]
|
||||||
|
headers = static_headers.copy()
|
||||||
try:
|
try:
|
||||||
full_path = (root_path / path).resolve().absolute()
|
full_path = (root_path / path).resolve().absolute()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
|
|
Ładowanie…
Reference in New Issue