Anirudh Esthuri commited on
Commit
1dbbeef
Β·
1 Parent(s): a56dead

Fix: Add error handling for missing files and use PORT env var correctly

Browse files
Files changed (2) hide show
  1. Dockerfile +2 -1
  2. app.py +9 -3
Dockerfile CHANGED
@@ -47,4 +47,5 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
47
  CMD curl --fail http://localhost:${PORT:-7860}/_stcore/health || exit 1
48
 
49
  # Run Streamlit app using PORT env var from Hugging Face Spaces
50
- CMD ["bash", "-c", "streamlit run app.py --server.address=0.0.0.0 --server.port=${PORT:-7860} --server.headless=true"]
 
 
47
  CMD curl --fail http://localhost:${PORT:-7860}/_stcore/health || exit 1
48
 
49
  # Run Streamlit app using PORT env var from Hugging Face Spaces
50
+ # HuggingFace sets $PORT, don't override it.
51
+ CMD ["bash", "-c", "streamlit run app.py --server.address=0.0.0.0 --server.port=$PORT --server.headless=true"]
app.py CHANGED
@@ -41,15 +41,21 @@ def rewrite_message(
41
  # Page setup & CSS
42
  # ──────────────────────────────────────────────────────────────
43
  st.set_page_config(page_title="MemMachine Chatbot", layout="wide")
44
- with open("./styles.css") as f:
45
- st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
 
 
 
46
 
47
 
48
  # ──────────────────────────────────────────────────────────────
49
  # Sidebar
50
  # ──────────────────────────────────────────────────────────────
51
  with st.sidebar:
52
- st.image("./assets/memmachine_logo.png", use_container_width=True)
 
 
 
53
 
54
  st.markdown("#### Choose Model")
55
 
 
41
  # Page setup & CSS
42
  # ──────────────────────────────────────────────────────────────
43
  st.set_page_config(page_title="MemMachine Chatbot", layout="wide")
44
+ try:
45
+ with open("./styles.css") as f:
46
+ st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
47
+ except FileNotFoundError:
48
+ st.markdown("<style></style>", unsafe_allow_html=True)
49
 
50
 
51
  # ──────────────────────────────────────────────────────────────
52
  # Sidebar
53
  # ──────────────────────────────────────────────────────────────
54
  with st.sidebar:
55
+ try:
56
+ st.image("./assets/memmachine_logo.png", use_container_width=True)
57
+ except FileNotFoundError:
58
+ st.markdown("### MemMachine")
59
 
60
  st.markdown("#### Choose Model")
61