Ashhar
flux client to replicate + words count
eb9c1db
raw
history blame
4.05 kB
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;
}
div.words-count {
font-size: 0.7rem !important;
color: green;
margin-top: -1rem;
text-align: right;
}
div.words-count.crossed-limit {
color: red;
font-size: 1rem !important;
}
</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