-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathstreamlit_app.py
More file actions
35 lines (26 loc) · 859 Bytes
/
streamlit_app.py
File metadata and controls
35 lines (26 loc) · 859 Bytes
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
28
29
30
31
32
33
34
35
import streamlit as st
from pathlib import Path
import shutil
from app.utils import app_main
@st.cache_data
def move_fonts_files(fonts_dir: str | Path):
"""
copying font files into stramlit path to be rendered correctly
"""
STREAMLIT_STATIC_PATH = Path(st.__path__[0]) / "static"
CSS_PATH = STREAMLIT_STATIC_PATH
for dir in ['assets', 'fonts']:
CSS_PATH = CSS_PATH / dir
if not CSS_PATH.is_dir():
CSS_PATH.mkdir()
font_files = Path(fonts_dir).glob('*')
for font_file in font_files:
shutil.copy(font_file, CSS_PATH)
@st.cache_data
def load_css(css_path: str | Path):
with open(Path(css_path)) as css:
st.markdown(f'<style>{css.read()}</style>', unsafe_allow_html=True)
if __name__ == "__main__":
move_fonts_files('app/fonts')
load_css("style.css")
app_main()