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}"