diff --git a/Dockerfile b/Dockerfile index e8c5c4e..0add9bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,7 +44,7 @@ USER nonroot # Run the Streamlit application by default ENV TZ="Asia/Taipei" EXPOSE 8800 -CMD ["python", "-m", "streamlit", "run", "app.py", "--server.port=8800", "--server.enableCORS=false", "--server.enableXsrfProtection=false"] +CMD ["python", "-m", "streamlit", "run", "app.py"] # Build # docker build --platform=linux/amd64 -t hiking_assistant:latest . diff --git a/hiking_assistant/.streamlit/config.toml b/hiking_assistant/.streamlit/config.toml new file mode 100644 index 0000000..1581790 --- /dev/null +++ b/hiking_assistant/.streamlit/config.toml @@ -0,0 +1,11 @@ +[theme] +base = "light" + +[server] +port = 8800 +enableCORS = false +enableXsrfProtection = false +maxUploadSize = 30 + +[client] +toolbarMode = "minimal" diff --git a/hiking_assistant/app.py b/hiking_assistant/app.py index e07066a..e373870 100644 --- a/hiking_assistant/app.py +++ b/hiking_assistant/app.py @@ -3,7 +3,9 @@ # author: deng # date: 20251127 +import base64 from datetime import datetime +from pathlib import Path import streamlit as st import yaml @@ -22,6 +24,48 @@ class HikingAssistant: with open('assets/config.yaml', 'r') as f: return yaml.safe_load(f) + def _set_background(self, image_path): + """Set background image for the application. + + Args: + image_path: Path to the background image + """ + + image_path = Path(image_path) + if not image_path.exists(): + return + + with open(image_path, 'rb') as f: + image_data = base64.b64encode(f.read()).decode() + + # Use file modification time as cache buster + cache_buster = int(image_path.stat().st_mtime) + + background_css = f""" + + """ + st.markdown(background_css, unsafe_allow_html=True) + def run(self): """Hiking Assistant application""" # Page configuration @@ -31,6 +75,7 @@ class HikingAssistant: layout='wide', initial_sidebar_state='collapsed', ) + self._set_background(self._config['app']['page_background_path']) # [Block1] # Title and description diff --git a/hiking_assistant/assets/background.jpg b/hiking_assistant/assets/background.jpg new file mode 100644 index 0000000..3c14373 Binary files /dev/null and b/hiking_assistant/assets/background.jpg differ diff --git a/hiking_assistant/assets/config.yaml b/hiking_assistant/assets/config.yaml index de0115b..b86d025 100644 --- a/hiking_assistant/assets/config.yaml +++ b/hiking_assistant/assets/config.yaml @@ -2,6 +2,7 @@ app: page_title: 臺灣登山小幫手 page_favicon_path: ./assets/favicon_compressed.jpg page_footer_text: ⚠️ 本服務提供之資訊僅供規劃參考,山區氣候瞬息萬變,請務必依據現場狀況與自身能力進行風險評估
Made with ❤️ by deng + page_background_path: ./assets/background.jpg altitude_sickness: elevation_threshold: 2100 warning_text: 此路線海拔較高,請留意[高山症](https://www.ysnp.gov.tw/StaticPage/MountainSickness)發生風險