diff --git a/e2e/scripts/assets/favicon.ico b/e2e/scripts/assets/favicon.ico new file mode 100644 index 000000000000..24591070884d Binary files /dev/null and b/e2e/scripts/assets/favicon.ico differ diff --git a/e2e/scripts/st_set_page_config_icon.py b/e2e/scripts/st_set_page_config_icon.py new file mode 100644 index 000000000000..1d074c64485b --- /dev/null +++ b/e2e/scripts/st_set_page_config_icon.py @@ -0,0 +1,5 @@ +import streamlit as st + +st.set_page_config( + page_icon="e2e/scripts/assets/favicon.ico", +) diff --git a/e2e/specs/st_set_page_config_icon.spec.js b/e2e/specs/st_set_page_config_icon.spec.js new file mode 100644 index 000000000000..0f92f5a3c99f --- /dev/null +++ b/e2e/specs/st_set_page_config_icon.spec.js @@ -0,0 +1,31 @@ +/** + * @license + * Copyright 2018-2022 Streamlit Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +describe("st.set_page_config with ICO", () => { + before(() => { + cy.loadApp("http://localhost:3000/"); + }); + + it("sets the page favicon with ico file", () => { + cy.get("link[rel='shortcut icon']") + .invoke("attr", "href") + .should( + "eq", + "http://localhost:8501/media/92018b2805266c4cb9a98e90c849ce5b5e7ba6d1af423bd7b7c345da.png" + ); + }); +}); diff --git a/lib/streamlit/elements/image.py b/lib/streamlit/elements/image.py index 7dcc9d034175..2eec49bf7318 100644 --- a/lib/streamlit/elements/image.py +++ b/lib/streamlit/elements/image.py @@ -207,6 +207,8 @@ def _normalize_to_bytes(data, width, output_format): if output_format.lower() == "auto": ext = imghdr.what(None, data) mimetype = mimetypes.guess_type("image.%s" % ext)[0] + if mimetype is None: + mimetype = "image/" + format.lower() else: mimetype = "image/" + format.lower()