Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,27 +5,28 @@ import streamlit as st
|
|
| 5 |
|
| 6 |
# ---------- PATHS (subfolder-safe) ----------
|
| 7 |
BASE_DIR = Path(__file__).parent # -> Landing_Page/
|
| 8 |
-
ASSETS
|
| 9 |
|
| 10 |
-
# ---------- CONTROLS (
|
| 11 |
-
HERO_LOGO_SIZE
|
| 12 |
-
CARD_THUMB_HEIGHT
|
| 13 |
-
|
|
|
|
| 14 |
|
| 15 |
# ---------- CONFIG ----------
|
| 16 |
COMPANY_NAME = "Smart Thinking"
|
| 17 |
-
TAGLINE
|
| 18 |
|
| 19 |
APP1 = {
|
| 20 |
"title": "ST_Geo_Mech",
|
| 21 |
-
"url":
|
| 22 |
-
"
|
| 23 |
"blurb": "Real-Time UCS Prediction",
|
| 24 |
}
|
| 25 |
APP2 = {
|
| 26 |
"title": "ST_Log_GR",
|
| 27 |
-
"url":
|
| 28 |
-
"
|
| 29 |
"blurb": "Real-Time GR Log Prediction",
|
| 30 |
}
|
| 31 |
LOGO_PATH = ASSETS / "logo.png"
|
|
@@ -34,123 +35,125 @@ LOGO_PATH = ASSETS / "logo.png"
|
|
| 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,
|
| 38 |
st.markdown(
|
| 39 |
f"""
|
| 40 |
<style>
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 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,
|
| 110 |
)
|
| 111 |
|
| 112 |
# ---------- IMAGE HELPERS ----------
|
| 113 |
-
def
|
| 114 |
-
if not path.exists():
|
| 115 |
-
return None
|
| 116 |
mime, _ = mimetypes.guess_type(path.name)
|
| 117 |
-
if not mime:
|
| 118 |
-
mime = "image/png"
|
| 119 |
b64 = base64.b64encode(path.read_bytes()).decode("utf-8")
|
| 120 |
return f"data:{mime};base64,{b64}"
|
| 121 |
|
| 122 |
-
def
|
| 123 |
-
uri =
|
| 124 |
if uri:
|
| 125 |
-
return f'<img class="
|
| 126 |
-
|
|
|
|
| 127 |
|
| 128 |
# ---------- HERO ----------
|
| 129 |
-
logo_html = img_or_placeholder(LOGO_PATH, "logo") if LOGO_PATH.exists() else ""
|
| 130 |
st.markdown(
|
| 131 |
-
'<div class="hero">'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
unsafe_allow_html=True,
|
| 133 |
)
|
| 134 |
|
| 135 |
-
# ----------
|
| 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 |
-
{
|
| 141 |
<h3>{escape(app['title'])}</h3>
|
| 142 |
<p>{escape(app['blurb'])}</p>
|
| 143 |
-
<
|
| 144 |
-
<a class="btn" href="{escape(app['url'])}" target="{target}">Open {escape(app['title'])}</a>
|
| 145 |
-
</div>
|
| 146 |
</div>
|
| 147 |
"""
|
| 148 |
-
|
| 149 |
-
html_grid = f"<div class='grid'>{app_card(APP1)}{app_card(APP2)}</div>"
|
| 150 |
-
st.markdown(html_grid, unsafe_allow_html=True)
|
| 151 |
|
| 152 |
-
#
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
# ---------- PATHS (subfolder-safe) ----------
|
| 7 |
BASE_DIR = Path(__file__).parent # -> Landing_Page/
|
| 8 |
+
ASSETS = BASE_DIR / "assets" # -> Landing_Page/assets/
|
| 9 |
|
| 10 |
+
# ---------- CONTROLS (easy knobs) ----------
|
| 11 |
+
HERO_LOGO_SIZE = 140 # px (company logo in the hero)
|
| 12 |
+
CARD_THUMB_HEIGHT = 180 # px (image area inside each card)
|
| 13 |
+
BUTTON_TEXT = "Click to Run APP"
|
| 14 |
+
OPEN_IN_NEW_TAB = False # set True to open links in a new browser tab
|
| 15 |
|
| 16 |
# ---------- CONFIG ----------
|
| 17 |
COMPANY_NAME = "Smart Thinking"
|
| 18 |
+
TAGLINE = "We Deliver Smart AI-Based Solutions For O&G Industry"
|
| 19 |
|
| 20 |
APP1 = {
|
| 21 |
"title": "ST_Geo_Mech",
|
| 22 |
+
"url": "https://smart-thinking-ucs.hf.space/",
|
| 23 |
+
"thumb": ASSETS / "app1.png",
|
| 24 |
"blurb": "Real-Time UCS Prediction",
|
| 25 |
}
|
| 26 |
APP2 = {
|
| 27 |
"title": "ST_Log_GR",
|
| 28 |
+
"url": "https://smart-thinking-gr.hf.space/",
|
| 29 |
+
"thumb": ASSETS / "app2.png",
|
| 30 |
"blurb": "Real-Time GR Log Prediction",
|
| 31 |
}
|
| 32 |
LOGO_PATH = ASSETS / "logo.png"
|
|
|
|
| 35 |
page_icon = str(LOGO_PATH) if LOGO_PATH.exists() else "🧭"
|
| 36 |
st.set_page_config(page_title=f"{COMPANY_NAME} — Apps", page_icon=page_icon, layout="wide")
|
| 37 |
|
| 38 |
+
# ---------- CSS (fit to 1 screen on desktop, center content) ----------
|
| 39 |
st.markdown(
|
| 40 |
f"""
|
| 41 |
<style>
|
| 42 |
+
html, body, [data-testid="stAppViewContainer"] {{ height: 100%; }}
|
| 43 |
+
[data-testid="stAppViewContainer"] > .main {{
|
| 44 |
+
min-height: 100vh;
|
| 45 |
+
}}
|
| 46 |
+
.block-container {{
|
| 47 |
+
max-width: 1100px;
|
| 48 |
+
min-height: 100vh;
|
| 49 |
+
display: flex; flex-direction: column; justify-content: center;
|
| 50 |
+
padding-top: 12px !important; padding-bottom: 12px !important;
|
| 51 |
+
}}
|
| 52 |
+
|
| 53 |
+
.hero {{ text-align:center; margin: 4px 0 16px; }}
|
| 54 |
+
.hero img {{
|
| 55 |
+
width: {HERO_LOGO_SIZE}px; max-width: 95vw; height: auto;
|
| 56 |
+
display: block; margin: 0 auto;
|
| 57 |
+
filter: drop-shadow(0 2px 8px rgba(0,0,0,.12));
|
| 58 |
+
}}
|
| 59 |
+
.hero h1 {{ font-size: 2.2rem; margin: .75rem 0 .25rem; }}
|
| 60 |
+
.hero p {{ color: #5a5f6a; margin: 0 auto; max-width: 720px; }}
|
| 61 |
+
|
| 62 |
+
/* Cards layout: 2 columns on desktop, stack on small screens */
|
| 63 |
+
@media (min-width: 901px) {{
|
| 64 |
+
.two-cols {{ display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }}
|
| 65 |
+
}}
|
| 66 |
+
@media (max-width: 900px) {{
|
| 67 |
+
.two-cols {{ display: grid; grid-template-columns: 1fr; gap: 16px; }}
|
| 68 |
+
}}
|
| 69 |
+
|
| 70 |
+
.card {{
|
| 71 |
+
background: #fff; border-radius: 16px; padding: 16px;
|
| 72 |
+
border: 1px solid rgba(0,0,0,.06);
|
| 73 |
+
box-shadow: 0 4px 18px rgba(0,0,0,.05);
|
| 74 |
+
transition: transform .12s ease, box-shadow .12s ease;
|
| 75 |
+
text-align: center; /* center everything */
|
| 76 |
+
}}
|
| 77 |
+
.card:hover {{ transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,0,0,.08); }}
|
| 78 |
+
|
| 79 |
+
.thumb {{
|
| 80 |
+
width: 100%;
|
| 81 |
+
height: {CARD_THUMB_HEIGHT}px;
|
| 82 |
+
border-radius: 14px;
|
| 83 |
+
border: 1px solid rgba(0,0,0,.06);
|
| 84 |
+
object-fit: contain; /* show full image, no crop */
|
| 85 |
+
background: #fff;
|
| 86 |
+
}}
|
| 87 |
+
|
| 88 |
+
.card h3 {{ margin: 12px 0 6px; }}
|
| 89 |
+
.card p {{ color: #5a5f6a; min-height: 36px; margin-bottom: 10px; }}
|
| 90 |
+
|
| 91 |
+
/* Light button, dark text */
|
| 92 |
+
.btn {{
|
| 93 |
+
display:inline-block; padding: 10px 14px; border-radius: 12px;
|
| 94 |
+
border: 1px solid #e5e7eb; text-decoration:none;
|
| 95 |
+
background: #f3f4f6; color: #111827; font-weight: 500;
|
| 96 |
+
}}
|
| 97 |
+
.btn:hover {{ background:#e5e7eb; }}
|
| 98 |
+
.footer {{ text-align:center; color:#8a9099; font-size: 0.9rem; margin-top: 8px; }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
</style>
|
| 100 |
""",
|
| 101 |
unsafe_allow_html=True,
|
| 102 |
)
|
| 103 |
|
| 104 |
# ---------- IMAGE HELPERS ----------
|
| 105 |
+
def data_uri(path: Path) -> str | None:
|
| 106 |
+
if not path.exists(): return None
|
|
|
|
| 107 |
mime, _ = mimetypes.guess_type(path.name)
|
| 108 |
+
if not mime: mime = "image/png"
|
|
|
|
| 109 |
b64 = base64.b64encode(path.read_bytes()).decode("utf-8")
|
| 110 |
return f"data:{mime};base64,{b64}"
|
| 111 |
|
| 112 |
+
def img_tag(path: Path, alt: str, cls: str) -> str:
|
| 113 |
+
uri = data_uri(path)
|
| 114 |
if uri:
|
| 115 |
+
return f'<img class="{cls}" src="{uri}" alt="{escape(alt)}" />'
|
| 116 |
+
# graceful placeholder
|
| 117 |
+
return f'<div class="{cls}" style="display:flex;align-items:center;justify-content:center;color:#50545c;background:linear-gradient(180deg,#f6f7fb,#eceff4);">{escape(alt)}</div>'
|
| 118 |
|
| 119 |
# ---------- HERO ----------
|
|
|
|
| 120 |
st.markdown(
|
| 121 |
+
'<div class="hero">'
|
| 122 |
+
+ (img_tag(LOGO_PATH, "logo", "") if LOGO_PATH.exists() else "")
|
| 123 |
+
+ f"<h1>{escape(COMPANY_NAME)}</h1>"
|
| 124 |
+
+ f"<p>{escape(TAGLINE)}</p>"
|
| 125 |
+
+ "</div>",
|
| 126 |
unsafe_allow_html=True,
|
| 127 |
)
|
| 128 |
|
| 129 |
+
# ---------- CARD HTML ----------
|
| 130 |
def app_card(app: dict) -> str:
|
| 131 |
target = "_blank" if OPEN_IN_NEW_TAB else "_self"
|
| 132 |
return f"""
|
| 133 |
<div class="card">
|
| 134 |
+
{img_tag(app['thumb'], app['title'], "thumb")}
|
| 135 |
<h3>{escape(app['title'])}</h3>
|
| 136 |
<p>{escape(app['blurb'])}</p>
|
| 137 |
+
<a class="btn" href="{escape(app['url'])}" target="{target}">{escape(BUTTON_TEXT)}</a>
|
|
|
|
|
|
|
| 138 |
</div>
|
| 139 |
"""
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
+
# Render as two separate markdown blocks (prevents partial escaping issues)
|
| 142 |
+
left = app_card(APP1)
|
| 143 |
+
right = app_card(APP2)
|
| 144 |
+
|
| 145 |
+
st.markdown('<div class="two-cols">', unsafe_allow_html=True)
|
| 146 |
+
st.markdown(left, unsafe_allow_html=True)
|
| 147 |
+
st.markdown(right, unsafe_allow_html=True)
|
| 148 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 149 |
+
|
| 150 |
+
# Footer
|
| 151 |
+
# =========================
|
| 152 |
+
st.markdown("""
|
| 153 |
+
<br><br><br>
|
| 154 |
+
<hr>
|
| 155 |
+
<div style='text-align:center;color:#6b7280;font-size:1.0em;'>
|
| 156 |
+
© 2025 Smart Thinking AI-Solutions Team. All rights reserved.<br>
|
| 157 |
+
Contact: <a href="mailto:smartthinking@smartthinking.com.sa">smartthinking@smartthinking.com.sa</a>
|
| 158 |
+
</div>
|
| 159 |
+
""", unsafe_allow_html=True)
|