UCS2014 commited on
Commit
41d63dd
·
verified ·
1 Parent(s): 020a54f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +104 -101
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 = BASE_DIR / "assets" # -> Landing_Page/assets/
9
 
10
- # ---------- CONTROLS (tweak these) ----------
11
- HERO_LOGO_SIZE = 100 # px (company logo size in the hero)
12
- CARD_THUMB_HEIGHT = 160 # 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"
17
- TAGLINE = "We Deliver Smart AI-Based Solutions For O&G Industry"
18
 
19
  APP1 = {
20
  "title": "ST_Geo_Mech",
21
- "url": "https://smart-thinking-ucs.hf.space/",
22
- "thumb_path": ASSETS / "app1.png",
23
  "blurb": "Real-Time UCS Prediction",
24
  }
25
  APP2 = {
26
  "title": "ST_Log_GR",
27
- "url": "https://smart-thinking-gr.hf.space/",
28
- "thumb_path": ASSETS / "app2.png",
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, 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,
110
  )
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)
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 img_or_placeholder(path: Path, alt: str) -> str:
123
- uri = to_data_uri(path)
124
  if uri:
125
- return f'<img class="thumb" src="{uri}" alt="{escape(alt)}" />'
126
- return f'<div class="thumb">{escape(alt)}</div>'
 
127
 
128
  # ---------- HERO ----------
129
- logo_html = img_or_placeholder(LOGO_PATH, "logo") if LOGO_PATH.exists() else ""
130
  st.markdown(
131
- '<div class="hero">' + logo_html + f"<h1>{COMPANY_NAME}</h1>" + f"<p>{TAGLINE}</p>" + "</div>",
 
 
 
 
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
- <div class="cta">Click to Run APP:
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
- # ---------- FOOTER ----------
153
- st.markdown(
154
- f"<div style='text-align:center; color:#8a9099; font-size: 0.9rem; margin-top: 8px;'>© {escape(COMPANY_NAME)}</div>",
155
- unsafe_allow_html=True,
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)