From d6d8710544e88a8b50fb62a7dabb301ca85f97e6 Mon Sep 17 00:00:00 2001 From: Joe Cheng Date: Tue, 27 Aug 2024 12:55:15 -0700 Subject: [PATCH] Fix KeyError when serving static files (#1648) --- shiny/http_staticfiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shiny/http_staticfiles.py b/shiny/http_staticfiles.py index 57950c223..b45ccd1fc 100644 --- a/shiny/http_staticfiles.py +++ b/shiny/http_staticfiles.py @@ -43,7 +43,7 @@ def file_response( **kwargs: Any, ) -> starlette.responses.Response: resp = super().file_response(full_path, *args, **kwargs) - if resp.headers["content-type"].startswith("text/plain"): + if resp.headers.get("content-type", "").startswith("text/plain"): correct_type = _utils.guess_mime_type(full_path) resp.headers["content-type"] = ( f"{correct_type}; charset={resp.charset}"