Spaces:
Runtime error
Runtime error
File size: 714 Bytes
99ff8e6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import streamlit as st
import base64
import validators
from pathlib import Path
def add_logo(logo_url: str, height: int = 120):
if validators.url(logo_url) is True:
logo = f"url({logo_url})"
else:
logo = f"url(data:image/png;base64,{base64.b64encode(Path(logo_url).read_bytes()).decode()})"
st.markdown(
f"""
<style>
[data-testid="stSidebarNav"] {{
background-image: {logo};
background-repeat: no-repeat;
background-size: contain;
padding-top: {height - 40}px;
background-position: 20px 20px
}}
</style>
""",
unsafe_allow_html=True,
) |