Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,16 @@
|
|
| 1 |
-
import base64
|
| 2 |
-
import mimetypes
|
| 3 |
from html import escape
|
| 4 |
from pathlib import Path
|
| 5 |
import streamlit as st
|
| 6 |
|
| 7 |
# ---------- PATHS (subfolder-safe) ----------
|
| 8 |
-
BASE_DIR = Path(__file__).parent
|
| 9 |
-
ASSETS = BASE_DIR / "assets"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# ---------- CONFIG ----------
|
| 12 |
COMPANY_NAME = "Smart Thinking"
|
|
@@ -24,34 +28,82 @@ APP2 = {
|
|
| 24 |
"thumb_path": ASSETS / "app2.png",
|
| 25 |
"blurb": "Real-Time GR Log Prediction",
|
| 26 |
}
|
| 27 |
-
|
| 28 |
LOGO_PATH = ASSETS / "logo.png"
|
| 29 |
|
| 30 |
# ---------- PAGE META ----------
|
| 31 |
page_icon = str(LOGO_PATH) if LOGO_PATH.exists() else "🧭"
|
| 32 |
st.set_page_config(page_title=f"{COMPANY_NAME} — Apps", page_icon=page_icon, layout="wide")
|
| 33 |
|
| 34 |
-
# ----------
|
| 35 |
st.markdown(
|
| 36 |
-
"""
|
| 37 |
<style>
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
</style>
|
| 56 |
""",
|
| 57 |
unsafe_allow_html=True,
|
|
@@ -59,7 +111,6 @@ st.markdown(
|
|
| 59 |
|
| 60 |
# ---------- IMAGE HELPERS ----------
|
| 61 |
def to_data_uri(path: Path) -> str | None:
|
| 62 |
-
"""Return a data: URI for an image path, or None if missing."""
|
| 63 |
if not path.exists():
|
| 64 |
return None
|
| 65 |
mime, _ = mimetypes.guess_type(path.name)
|
|
@@ -81,14 +132,15 @@ st.markdown(
|
|
| 81 |
unsafe_allow_html=True,
|
| 82 |
)
|
| 83 |
|
| 84 |
-
# ----------
|
| 85 |
def app_card(app: dict) -> str:
|
|
|
|
| 86 |
return f"""
|
| 87 |
<div class="card">
|
| 88 |
{img_or_placeholder(app['thumb_path'], app['title'])}
|
| 89 |
<h3>{escape(app['title'])}</h3>
|
| 90 |
<p>{escape(app['blurb'])}</p>
|
| 91 |
-
<a class="btn
|
| 92 |
</div>
|
| 93 |
"""
|
| 94 |
|
|
@@ -97,6 +149,6 @@ st.markdown(html_grid, unsafe_allow_html=True)
|
|
| 97 |
|
| 98 |
# ---------- FOOTER ----------
|
| 99 |
st.markdown(
|
| 100 |
-
f"
|
| 101 |
unsafe_allow_html=True,
|
| 102 |
)
|
|
|
|
| 1 |
+
import base64, mimetypes
|
|
|
|
| 2 |
from html import escape
|
| 3 |
from pathlib import Path
|
| 4 |
import streamlit as st
|
| 5 |
|
| 6 |
# ---------- PATHS (subfolder-safe) ----------
|
| 7 |
+
BASE_DIR = Path(__file__).parent # -> Landing_Page/
|
| 8 |
+
ASSETS = BASE_DIR / "assets" # -> Landing_Page/assets/
|
| 9 |
+
|
| 10 |
+
# ---------- CONTROLS (tweak these) ----------
|
| 11 |
+
HERO_LOGO_SIZE = 120 # px (company logo size in the hero)
|
| 12 |
+
CARD_THUMB_HEIGHT = 180 # px (height of each app image)
|
| 13 |
+
OPEN_IN_NEW_TAB = False # set True if you want links to open in a new tab
|
| 14 |
|
| 15 |
# ---------- CONFIG ----------
|
| 16 |
COMPANY_NAME = "Smart Thinking"
|
|
|
|
| 28 |
"thumb_path": ASSETS / "app2.png",
|
| 29 |
"blurb": "Real-Time GR Log Prediction",
|
| 30 |
}
|
|
|
|
| 31 |
LOGO_PATH = ASSETS / "logo.png"
|
| 32 |
|
| 33 |
# ---------- PAGE META ----------
|
| 34 |
page_icon = str(LOGO_PATH) if LOGO_PATH.exists() else "🧭"
|
| 35 |
st.set_page_config(page_title=f"{COMPANY_NAME} — Apps", page_icon=page_icon, layout="wide")
|
| 36 |
|
| 37 |
+
# ---------- CSS (fit to 1 screen, centered layout) ----------
|
| 38 |
st.markdown(
|
| 39 |
+
f"""
|
| 40 |
<style>
|
| 41 |
+
html, body, [data-testid="stAppViewContainer"] {{
|
| 42 |
+
height: 100%;
|
| 43 |
+
}}
|
| 44 |
+
/* Center all content vertically and avoid scroll on desktop */
|
| 45 |
+
[data-testid="stAppViewContainer"] > .main {{
|
| 46 |
+
height: 100vh;
|
| 47 |
+
}}
|
| 48 |
+
.block-container {{
|
| 49 |
+
max-width: 1100px;
|
| 50 |
+
min-height: 100vh;
|
| 51 |
+
display: flex;
|
| 52 |
+
flex-direction: column;
|
| 53 |
+
justify-content: center;
|
| 54 |
+
padding-top: 0.5rem !important;
|
| 55 |
+
padding-bottom: 0.5rem !important;
|
| 56 |
+
}}
|
| 57 |
+
|
| 58 |
+
.hero {{ text-align:center; margin: 0 0 1.25rem; }}
|
| 59 |
+
.hero img {{ width: {HERO_LOGO_SIZE}px; height: auto; filter: drop-shadow(0 2px 8px rgba(0,0,0,.12)); }}
|
| 60 |
+
.hero h1 {{ font-size: 2.2rem; margin: .75rem 0 .25rem; }}
|
| 61 |
+
.hero p {{ color: #5a5f6a; margin: 0 auto; max-width: 720px; }}
|
| 62 |
+
|
| 63 |
+
.grid {{
|
| 64 |
+
display: grid;
|
| 65 |
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
| 66 |
+
gap: 20px;
|
| 67 |
+
align-items: start;
|
| 68 |
+
}}
|
| 69 |
+
@media (max-width: 1100px) {{
|
| 70 |
+
.grid {{ gap: 16px; }}
|
| 71 |
+
}}
|
| 72 |
+
@media (max-width: 900px) {{
|
| 73 |
+
/* fall back to vertical on small screens (might scroll there) */
|
| 74 |
+
.grid {{ grid-template-columns: 1fr; }}
|
| 75 |
+
}}
|
| 76 |
+
|
| 77 |
+
.card {{
|
| 78 |
+
background: white;
|
| 79 |
+
border-radius: 16px;
|
| 80 |
+
padding: 16px;
|
| 81 |
+
border: 1px solid rgba(0,0,0,.06);
|
| 82 |
+
box-shadow: 0 4px 18px rgba(0,0,0,.05);
|
| 83 |
+
transition: transform .12s ease, box-shadow .12s ease;
|
| 84 |
+
text-align: center; /* center title/desc/button */
|
| 85 |
+
}}
|
| 86 |
+
.card:hover {{ transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,0,0,.08); }}
|
| 87 |
+
|
| 88 |
+
.thumb {{
|
| 89 |
+
width: 100%;
|
| 90 |
+
height: {CARD_THUMB_HEIGHT}px;
|
| 91 |
+
border-radius: 14px;
|
| 92 |
+
border: 1px solid rgba(0,0,0,.06);
|
| 93 |
+
object-fit: contain; /* show whole image (no crop) */
|
| 94 |
+
background: white; /* clean background around contained image */
|
| 95 |
+
}}
|
| 96 |
+
|
| 97 |
+
.card h3 {{ margin: 12px 0 6px; }}
|
| 98 |
+
.card p {{ color: #5a5f6a; min-height: 36px; margin-bottom: 10px; }}
|
| 99 |
+
|
| 100 |
+
/* Light button with dark text */
|
| 101 |
+
.btn {{
|
| 102 |
+
display:inline-block; padding: 10px 14px; border-radius: 12px;
|
| 103 |
+
border: 1px solid #e5e7eb; text-decoration:none;
|
| 104 |
+
background: #f3f4f6; color: #111827;
|
| 105 |
+
}}
|
| 106 |
+
.btn:hover {{ background:#e5e7eb; }}
|
| 107 |
</style>
|
| 108 |
""",
|
| 109 |
unsafe_allow_html=True,
|
|
|
|
| 111 |
|
| 112 |
# ---------- IMAGE HELPERS ----------
|
| 113 |
def to_data_uri(path: Path) -> str | None:
|
|
|
|
| 114 |
if not path.exists():
|
| 115 |
return None
|
| 116 |
mime, _ = mimetypes.guess_type(path.name)
|
|
|
|
| 132 |
unsafe_allow_html=True,
|
| 133 |
)
|
| 134 |
|
| 135 |
+
# ---------- CARDS ----------
|
| 136 |
def app_card(app: dict) -> str:
|
| 137 |
+
target = "_blank" if OPEN_IN_NEW_TAB else "_self"
|
| 138 |
return f"""
|
| 139 |
<div class="card">
|
| 140 |
{img_or_placeholder(app['thumb_path'], app['title'])}
|
| 141 |
<h3>{escape(app['title'])}</h3>
|
| 142 |
<p>{escape(app['blurb'])}</p>
|
| 143 |
+
<a class="btn" href="{escape(app['url'])}" target="{target}">Open {escape(app['title'])}</a>
|
| 144 |
</div>
|
| 145 |
"""
|
| 146 |
|
|
|
|
| 149 |
|
| 150 |
# ---------- FOOTER ----------
|
| 151 |
st.markdown(
|
| 152 |
+
f"<div style='text-align:center; color:#8a9099; font-size: 0.9rem; margin-top: 8px;'>© {escape(COMPANY_NAME)}</div>",
|
| 153 |
unsafe_allow_html=True,
|
| 154 |
)
|