-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil_web.py
More file actions
75 lines (48 loc) · 1.37 KB
/
util_web.py
File metadata and controls
75 lines (48 loc) · 1.37 KB
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
import urllib.parse
from typing import *
import streamlit as st
from util_decorator import *
AppTitle = 'AtoCode'
AppIcon = '🚀'
AppAbout = '# This is AutoCode by Thomas!'
def appTitle():
return AppTitle
def appIcon():
return AppIcon
def appAbout():
return AppAbout
def getSessionState(k: str) -> Any:
if k not in st.session_state:
None
else:
return st.session_state[k]
@log
def setSessionState(k: str, v: Any):
st.session_state[k] = v
def hasSessionState(k: str) -> bool:
return k in st.session_state
def initPage():
st.set_page_config(
page_title=appTitle(),
page_icon=appIcon(),
layout="wide",
initial_sidebar_state="expanded",
menu_items={'About': appAbout()}
)
def colorText(color: str, txt: str) -> str:
return f":{color}[{txt}]"
def urlText(txt: str, url: str) -> str:
return f"[{txt}]({url})"
def blank(n):
return ' ' * n
def getUrl():
session = st.runtime.get_instance()._session_mgr.list_active_sessions()[0]
st_base_url = urllib.parse.urlunparse(
[session.client.request.protocol, session.client.request.host, "", "", "", ""])
print(session.client.request.protocol)
print(session.client.request.host)
print(session.client.request)
return st_base_url
if __name__ == '__main__':
pass
print(orangeText('hello'))