Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
|
|
| 1 |
import base64, mimetypes
|
| 2 |
from html import escape
|
| 3 |
from pathlib import Path
|
| 4 |
import streamlit as st
|
| 5 |
|
| 6 |
-
# ========= PATHS
|
| 7 |
-
BASE_DIR = Path(__file__).parent
|
| 8 |
-
ASSETS = BASE_DIR / "assets"
|
| 9 |
|
| 10 |
# ========= CONTROLS =========
|
| 11 |
-
HERO_LOGO_SIZE = 172
|
| 12 |
-
TOP_SPACER = 140
|
| 13 |
-
GRID_GAP = 48
|
| 14 |
BUTTON_TEXT = "Open App"
|
| 15 |
OPEN_IN_NEW_TAB = False
|
| 16 |
|
| 17 |
-
# BRAND (
|
| 18 |
COMPANY_NAME = "Smart Thinking - Logging"
|
| 19 |
TAGLINE = "We Deliver Smart AI-Based Solutions For O&G Industry"
|
| 20 |
SUITE_NAME = "ST_LOG SUITE"
|
| 21 |
-
ACCENT = "#0E7490"
|
| 22 |
-
ACCENT_END = "#14B8A6"
|
| 23 |
-
ACCENT_SOFT = "rgba(14,116,144,0.15)"
|
| 24 |
|
| 25 |
# ========= APPS =========
|
| 26 |
APP1 = {
|
| 27 |
"title": "ST_Log_GR",
|
| 28 |
"url": "https://smart-thinking-gr.hf.space/",
|
| 29 |
"blurb": "Real-time gamma-ray log prediction.",
|
| 30 |
-
"icon": ASSETS / "app1_icon.png", # tiny glyph (
|
| 31 |
}
|
| 32 |
APP2 = {
|
| 33 |
"title": "ST_Log_Sonic (Ts)",
|
|
@@ -44,10 +44,13 @@ APP3 = {
|
|
| 44 |
|
| 45 |
LOGO_PATH = ASSETS / "logo.png"
|
| 46 |
|
| 47 |
-
# ========= PAGE META =========
|
| 48 |
page_icon = str(LOGO_PATH) if LOGO_PATH.exists() else "🧭"
|
| 49 |
st.set_page_config(page_title=f"{COMPANY_NAME} — Apps", page_icon=page_icon, layout="wide")
|
| 50 |
|
|
|
|
|
|
|
|
|
|
| 51 |
# ========= HELPERS =========
|
| 52 |
def data_uri(path: Path) -> str | None:
|
| 53 |
if not path or not path.exists():
|
|
@@ -63,12 +66,12 @@ def img_tag(path: Path, alt: str, cls: str = "") -> str:
|
|
| 63 |
if uri:
|
| 64 |
cls_attr = f' class="{cls}"' if cls else ""
|
| 65 |
return f'<img{cls_attr} src="{uri}" alt="{escape(alt)}" />'
|
| 66 |
-
#
|
| 67 |
-
return f'<div class="{cls}" style="display:flex;align-items:center;justify-content:center;color:#50545c;background:
|
| 68 |
|
| 69 |
def card_header_badge(icon_path: Path | None, suite_label: str) -> str:
|
| 70 |
icon_uri = data_uri(icon_path) if icon_path else None
|
| 71 |
-
icon_html = f"<img src='{icon_uri}' alt='icon' style='width:22px;height:22px;'>" if icon_uri else ""
|
| 72 |
return f"""
|
| 73 |
<div class="badge">
|
| 74 |
<div class="badge-left">{icon_html}</div>
|
|
@@ -76,65 +79,67 @@ def card_header_badge(icon_path: Path | None, suite_label: str) -> str:
|
|
| 76 |
</div>
|
| 77 |
"""
|
| 78 |
|
|
|
|
|
|
|
| 79 |
def inject_subtle_bg() -> None:
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
<path d='M0 16 H32 M16 0 V32' stroke='rgba(15,23,42,0.06)' stroke-width='1'/>
|
| 90 |
-
</pattern>
|
| 91 |
-
</defs>
|
| 92 |
-
<rect width='100%' height='100%' fill='url(#p)'/>
|
| 93 |
-
</svg>
|
| 94 |
-
""".strip()
|
| 95 |
|
| 96 |
st.markdown(f"""
|
| 97 |
<style>
|
|
|
|
| 98 |
.stApp {{
|
| 99 |
-
position: relative;
|
| 100 |
background:
|
| 101 |
-
radial-gradient(
|
| 102 |
-
rgba(20,184,166,0.
|
| 103 |
-
rgba(14,116,144,0.
|
| 104 |
-
rgba(255,255,255,0.
|
| 105 |
rgba(255,255,255,1) 100%) !important;
|
| 106 |
}}
|
|
|
|
| 107 |
.stApp::before {{
|
| 108 |
content: "";
|
| 109 |
position: fixed; inset: 0; z-index: 0;
|
| 110 |
background-image: url("{pattern_svg}");
|
| 111 |
-
opacity: .
|
| 112 |
pointer-events: none;
|
| 113 |
}}
|
|
|
|
| 114 |
.stApp > * {{ position: relative; z-index: 1; }}
|
| 115 |
-
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
</style>
|
| 118 |
""", unsafe_allow_html=True)
|
| 119 |
|
| 120 |
-
# Apply subtle background
|
| 121 |
inject_subtle_bg()
|
| 122 |
|
| 123 |
-
# ========= CORE CSS =========
|
| 124 |
st.markdown(
|
| 125 |
f"""
|
| 126 |
<style>
|
| 127 |
:root {{
|
| 128 |
--top-spacer: {TOP_SPACER}px;
|
| 129 |
--grid-gap: {GRID_GAP}px;
|
| 130 |
-
--grid-top-space: 28px;
|
| 131 |
--brand: {ACCENT};
|
| 132 |
--brand2: {ACCENT_END};
|
| 133 |
-
--brandSoft: {ACCENT_SOFT};
|
| 134 |
}}
|
| 135 |
|
| 136 |
html, body, [data-testid="stAppViewContainer"] {{ height: 100%; }}
|
| 137 |
-
[data-testid="stAppViewContainer"] > .main {{
|
|
|
|
|
|
|
| 138 |
|
| 139 |
.block-container {{
|
| 140 |
max-width: 1080px;
|
|
@@ -153,10 +158,9 @@ st.markdown(
|
|
| 153 |
filter: drop-shadow(0 4px 14px rgba(0,0,0,.10));
|
| 154 |
}}
|
| 155 |
.hero h1 {{
|
| 156 |
-
font-size: 2.
|
| 157 |
letter-spacing: .3px;
|
| 158 |
color: #0F172A;
|
| 159 |
-
text-shadow: 0 1px 0 rgba(255,255,255,.65);
|
| 160 |
}}
|
| 161 |
.hero p {{
|
| 162 |
color: #364152;
|
|
@@ -187,7 +191,7 @@ st.markdown(
|
|
| 187 |
gap: 48px;
|
| 188 |
justify-content: center;
|
| 189 |
align-items: stretch;
|
| 190 |
-
margin-top:
|
| 191 |
}}
|
| 192 |
@media (max-width: 1024px) {{
|
| 193 |
.grid {{ grid-template-columns: repeat(2, 260px); gap: 36px; }}
|
|
@@ -199,9 +203,9 @@ st.markdown(
|
|
| 199 |
/* CARD */
|
| 200 |
.card {{
|
| 201 |
width: 260px;
|
| 202 |
-
background: rgba(255,255,255,0.
|
| 203 |
border: 1px solid rgba(2,20,35,.06);
|
| 204 |
-
border-radius:
|
| 205 |
box-shadow: 0 6px 28px rgba(2,20,35,.06);
|
| 206 |
transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
|
| 207 |
text-align:center; display:flex; flex-direction:column; gap:10px;
|
|
@@ -211,10 +215,10 @@ st.markdown(
|
|
| 211 |
.card:hover {{
|
| 212 |
transform: translateY(-4px);
|
| 213 |
box-shadow: 0 14px 40px rgba(2,20,35,.12);
|
| 214 |
-
border-color:
|
| 215 |
}}
|
| 216 |
|
| 217 |
-
/* BADGE (replaces
|
| 218 |
.badge {{
|
| 219 |
width:100%;
|
| 220 |
display:flex; align-items:center; justify-content:flex-start;
|
|
@@ -241,7 +245,7 @@ st.markdown(
|
|
| 241 |
color:#495464; min-height: 32px; margin: 6px 6px 0; font-size: .95rem;
|
| 242 |
}}
|
| 243 |
|
| 244 |
-
/* BUTTON
|
| 245 |
.btn {{
|
| 246 |
display:inline-block; padding:10px 16px; border-radius:12px;
|
| 247 |
border:1px solid rgba(14,116,144,0.25); text-decoration:none;
|
|
@@ -264,16 +268,19 @@ st.markdown(
|
|
| 264 |
)
|
| 265 |
|
| 266 |
# ========= HERO =========
|
|
|
|
|
|
|
|
|
|
| 267 |
st.markdown(
|
| 268 |
'<div class="hero">'
|
| 269 |
-
+ (
|
| 270 |
+ f"<h1>{escape(COMPANY_NAME)}</h1>"
|
| 271 |
+ f"<p>{escape(TAGLINE)}</p>"
|
| 272 |
+ "</div>",
|
| 273 |
unsafe_allow_html=True,
|
| 274 |
)
|
| 275 |
|
| 276 |
-
# ========= SUITE BANNER
|
| 277 |
st.markdown(
|
| 278 |
f"""
|
| 279 |
<div class="suite-banner">
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
import base64, mimetypes
|
| 3 |
from html import escape
|
| 4 |
from pathlib import Path
|
| 5 |
import streamlit as st
|
| 6 |
|
| 7 |
+
# ========= PATHS =========
|
| 8 |
+
BASE_DIR = Path(__file__).parent
|
| 9 |
+
ASSETS = BASE_DIR / "assets"
|
| 10 |
|
| 11 |
# ========= CONTROLS =========
|
| 12 |
+
HERO_LOGO_SIZE = 172
|
| 13 |
+
TOP_SPACER = 140
|
| 14 |
+
GRID_GAP = 48
|
| 15 |
BUTTON_TEXT = "Open App"
|
| 16 |
OPEN_IN_NEW_TAB = False
|
| 17 |
|
| 18 |
+
# BRAND (Logging suite)
|
| 19 |
COMPANY_NAME = "Smart Thinking - Logging"
|
| 20 |
TAGLINE = "We Deliver Smart AI-Based Solutions For O&G Industry"
|
| 21 |
SUITE_NAME = "ST_LOG SUITE"
|
| 22 |
+
ACCENT = "#0E7490" # start
|
| 23 |
+
ACCENT_END = "#14B8A6" # end
|
|
|
|
| 24 |
|
| 25 |
# ========= APPS =========
|
| 26 |
APP1 = {
|
| 27 |
"title": "ST_Log_GR",
|
| 28 |
"url": "https://smart-thinking-gr.hf.space/",
|
| 29 |
"blurb": "Real-time gamma-ray log prediction.",
|
| 30 |
+
"icon": ASSETS / "app1_icon.png", # optional tiny glyph (24–32px)
|
| 31 |
}
|
| 32 |
APP2 = {
|
| 33 |
"title": "ST_Log_Sonic (Ts)",
|
|
|
|
| 44 |
|
| 45 |
LOGO_PATH = ASSETS / "logo.png"
|
| 46 |
|
| 47 |
+
# ========= PAGE META (set first) =========
|
| 48 |
page_icon = str(LOGO_PATH) if LOGO_PATH.exists() else "🧭"
|
| 49 |
st.set_page_config(page_title=f"{COMPANY_NAME} — Apps", page_icon=page_icon, layout="wide")
|
| 50 |
|
| 51 |
+
# Quick debug line so you can confirm the script rendered
|
| 52 |
+
st.caption("✅ Page loaded. If you ever see a blank page, this line helps diagnose execution.")
|
| 53 |
+
|
| 54 |
# ========= HELPERS =========
|
| 55 |
def data_uri(path: Path) -> str | None:
|
| 56 |
if not path or not path.exists():
|
|
|
|
| 66 |
if uri:
|
| 67 |
cls_attr = f' class="{cls}"' if cls else ""
|
| 68 |
return f'<img{cls_attr} src="{uri}" alt="{escape(alt)}" />'
|
| 69 |
+
# simple fallback if missing
|
| 70 |
+
return f'<div class="{cls}" style="display:flex;align-items:center;justify-content:center;color:#50545c;background:#eef2f7;border-radius:8px;">{escape(alt)}</div>'
|
| 71 |
|
| 72 |
def card_header_badge(icon_path: Path | None, suite_label: str) -> str:
|
| 73 |
icon_uri = data_uri(icon_path) if icon_path else None
|
| 74 |
+
icon_html = f"<img src='{icon_uri}' alt='icon' style='width:22px;height:22px;display:block;'>" if icon_uri else ""
|
| 75 |
return f"""
|
| 76 |
<div class="badge">
|
| 77 |
<div class="badge-left">{icon_html}</div>
|
|
|
|
| 79 |
</div>
|
| 80 |
"""
|
| 81 |
|
| 82 |
+
# ========= BACKGROUND (simple & safe) =========
|
| 83 |
+
# No images, no complex CSS: just a soft gradient + very faint SVG grid pattern
|
| 84 |
def inject_subtle_bg() -> None:
|
| 85 |
+
pattern_svg = (
|
| 86 |
+
"data:image/svg+xml;utf8,"
|
| 87 |
+
"<svg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'>"
|
| 88 |
+
"<defs><pattern id='p' width='32' height='32' patternUnits='userSpaceOnUse'>"
|
| 89 |
+
"<path d='M0 16 H32 M16 0 V32' stroke='rgba(15,23,42,0.06)' stroke-width='1'/>"
|
| 90 |
+
"</pattern></defs>"
|
| 91 |
+
"<rect width='100%' height='100%' fill='url(#p)'/>"
|
| 92 |
+
"</svg>"
|
| 93 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
st.markdown(f"""
|
| 96 |
<style>
|
| 97 |
+
/* Base gradient */
|
| 98 |
.stApp {{
|
| 99 |
+
position: relative !important;
|
| 100 |
background:
|
| 101 |
+
radial-gradient(900px 420px at 50% 0%,
|
| 102 |
+
rgba(20,184,166,0.12) 0%,
|
| 103 |
+
rgba(14,116,144,0.08) 32%,
|
| 104 |
+
rgba(255,255,255,0.94) 70%,
|
| 105 |
rgba(255,255,255,1) 100%) !important;
|
| 106 |
}}
|
| 107 |
+
/* Faint pattern on top of the gradient */
|
| 108 |
.stApp::before {{
|
| 109 |
content: "";
|
| 110 |
position: fixed; inset: 0; z-index: 0;
|
| 111 |
background-image: url("{pattern_svg}");
|
| 112 |
+
opacity: .45;
|
| 113 |
pointer-events: none;
|
| 114 |
}}
|
| 115 |
+
/* Ensure all content sits above */
|
| 116 |
.stApp > * {{ position: relative; z-index: 1; }}
|
| 117 |
+
|
| 118 |
+
[data-testid="stAppViewContainer"],
|
| 119 |
+
[data-testid="stAppViewContainer"] > .main,
|
| 120 |
+
html, body {{
|
| 121 |
+
background: transparent !important;
|
| 122 |
+
}}
|
| 123 |
</style>
|
| 124 |
""", unsafe_allow_html=True)
|
| 125 |
|
|
|
|
| 126 |
inject_subtle_bg()
|
| 127 |
|
| 128 |
+
# ========= CORE CSS (lean & reliable) =========
|
| 129 |
st.markdown(
|
| 130 |
f"""
|
| 131 |
<style>
|
| 132 |
:root {{
|
| 133 |
--top-spacer: {TOP_SPACER}px;
|
| 134 |
--grid-gap: {GRID_GAP}px;
|
|
|
|
| 135 |
--brand: {ACCENT};
|
| 136 |
--brand2: {ACCENT_END};
|
|
|
|
| 137 |
}}
|
| 138 |
|
| 139 |
html, body, [data-testid="stAppViewContainer"] {{ height: 100%; }}
|
| 140 |
+
[data-testid="stAppViewContainer"] > .main {{
|
| 141 |
+
padding-top: 0 !important; padding-bottom: 0 !important;
|
| 142 |
+
}}
|
| 143 |
|
| 144 |
.block-container {{
|
| 145 |
max-width: 1080px;
|
|
|
|
| 158 |
filter: drop-shadow(0 4px 14px rgba(0,0,0,.10));
|
| 159 |
}}
|
| 160 |
.hero h1 {{
|
| 161 |
+
font-size: 2.4rem; line-height: 1.15; margin: .25rem 0 .25rem;
|
| 162 |
letter-spacing: .3px;
|
| 163 |
color: #0F172A;
|
|
|
|
| 164 |
}}
|
| 165 |
.hero p {{
|
| 166 |
color: #364152;
|
|
|
|
| 191 |
gap: 48px;
|
| 192 |
justify-content: center;
|
| 193 |
align-items: stretch;
|
| 194 |
+
margin-top: 24px;
|
| 195 |
}}
|
| 196 |
@media (max-width: 1024px) {{
|
| 197 |
.grid {{ grid-template-columns: repeat(2, 260px); gap: 36px; }}
|
|
|
|
| 203 |
/* CARD */
|
| 204 |
.card {{
|
| 205 |
width: 260px;
|
| 206 |
+
background: rgba(255,255,255,0.94);
|
| 207 |
border: 1px solid rgba(2,20,35,.06);
|
| 208 |
+
border-radius:16px; padding:16px 14px;
|
| 209 |
box-shadow: 0 6px 28px rgba(2,20,35,.06);
|
| 210 |
transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
|
| 211 |
text-align:center; display:flex; flex-direction:column; gap:10px;
|
|
|
|
| 215 |
.card:hover {{
|
| 216 |
transform: translateY(-4px);
|
| 217 |
box-shadow: 0 14px 40px rgba(2,20,35,.12);
|
| 218 |
+
border-color: rgba(14,116,144,0.22);
|
| 219 |
}}
|
| 220 |
|
| 221 |
+
/* BADGE (replaces large logos) */
|
| 222 |
.badge {{
|
| 223 |
width:100%;
|
| 224 |
display:flex; align-items:center; justify-content:flex-start;
|
|
|
|
| 245 |
color:#495464; min-height: 32px; margin: 6px 6px 0; font-size: .95rem;
|
| 246 |
}}
|
| 247 |
|
| 248 |
+
/* BUTTON */
|
| 249 |
.btn {{
|
| 250 |
display:inline-block; padding:10px 16px; border-radius:12px;
|
| 251 |
border:1px solid rgba(14,116,144,0.25); text-decoration:none;
|
|
|
|
| 268 |
)
|
| 269 |
|
| 270 |
# ========= HERO =========
|
| 271 |
+
def img_or_blank(path: Path) -> str:
|
| 272 |
+
return img_tag(path, "logo", "") if path.exists() else ""
|
| 273 |
+
|
| 274 |
st.markdown(
|
| 275 |
'<div class="hero">'
|
| 276 |
+
+ img_or_blank(LOGO_PATH)
|
| 277 |
+ f"<h1>{escape(COMPANY_NAME)}</h1>"
|
| 278 |
+ f"<p>{escape(TAGLINE)}</p>"
|
| 279 |
+ "</div>",
|
| 280 |
unsafe_allow_html=True,
|
| 281 |
)
|
| 282 |
|
| 283 |
+
# ========= SUITE BANNER =========
|
| 284 |
st.markdown(
|
| 285 |
f"""
|
| 286 |
<div class="suite-banner">
|