File size: 3,771 Bytes
c1f566c e8511c9 c1f566c 71a2c91 c1f566c 71a2c91 c1f566c 71a2c91 c1f566c db7b744 ffd533c db7b744 21999ba c1f566c e8511c9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
import streamlit as st
import datetime as DT
import pytz
import requests
FONTS = [
# "Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900",
# "Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900",
# "Raleway:ital,wght@0,100..900;1,100..900",
# "Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900",
# "Nunito:ital,wght@0,200..1000;1,200..1000",
# "Quicksand:[email protected]",
# "Montserrat:ital,wght@0,100..900;1,100..900",
# "Edu+AU+VIC+WA+NT+Dots:[email protected]",
"Whisper",
# "Merienda:[email protected]",
# "Playwrite+DE+Grund:[email protected]",
# "Roboto+Slab:[email protected]",
"Open+Sans:ital,wght@0,300..800;1,300..800",
"Nunito+Sans:ital,opsz,wght@0,6..12,200..1000;1,6..12,200..1000",
"Ubuntu:ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700",
]
def __nowInIST() -> DT.datetime:
return DT.datetime.now(pytz.timezone("Asia/Kolkata"))
def pprint(log: str):
now = __nowInIST()
now = now.strftime("%Y-%m-%d %H:%M:%S")
print(f"[{now}] [{st.session_state.ipAddress}] {log}")
def __getFontsUrl():
baseLink = "https://fonts.googleapis.com/css2"
params = "&".join([f"family={font}" for font in FONTS])
params = f"{params}&display=swap"
fontsUrl = f"{baseLink}?{params}"
# pprint(f"{fontsUrl=}")
return fontsUrl
def applyCommonStyles():
st.markdown(
f"""
<head>
<link href="{__getFontsUrl()}" rel="stylesheet">
</head>
""" """
<style>
h1 {
font-family: 'Whisper';
}
h3, div[data-testid="stMarkdownContainer"], .stChatInput textarea, .stButton p {
font-family: 'Ubuntu';
# font-weight: 300;
}
div[data-testid="stMarkdownContainer"] *:not(h1):not(h2):not(h3):not(h4):not(h5):not(h6) {
font-size: 0.9rem;
}
.stButton p {
font-size: 0.9rem !important;
}
@keyframes blinker {
0% {
opacity: 1;
}
50% {
opacity: 0.2;
}
100% {
opacity: 1;
}
}
.blinking {
animation: blinker 3s ease-out infinite;
}
.code {
color: green;
border-radius: 3px;
padding: 2px 4px; /* Padding around the text */
font-family: 'Courier New', Courier, monospace; /* Monospace font */
}
.large {
font-size: 15px;
}
.bold {
font-weight: bold;
}
div[aria-label="dialog"] {
width: 80vw;
height: 620px;
}
div.stSpinner {
margin-left: auto;
margin-right: auto;
margin-top: 1rem;
width: fit-content;
}
div.stAlert {
margin-top: 1rem;
}
section[data-testid="stSidebar"] {
background-color: #1a1c23 !important;
}
div[data-testid="stSidebarUserContent"] {
padding-bottom: 1rem !important;
}
div[data-testid="stMarkdownContainer"] > hr {
margin-top: 0.5rem;
margin-bottom: 1rem;
}
</style>
""",
unsafe_allow_html=True
)
def isValidImageUrl(url):
if not url:
return False
try:
imageResponse = requests.head(url, timeout=5)
contentType = imageResponse.headers.get('Content-Type', '')
return imageResponse.status_code == 200 and contentType.startswith('image/')
except Exception:
return False
|