yuanjie commited on
Commit
3369999
1 Parent(s): 7ecff83
.streamlit/_config.toml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [theme]
2
+ font = "sans serif"
3
+ textColor = "#1F5BAC"
4
+ primaryColor = "#1F5BAC"
5
+ backgroundColor = "#FFFFFF"
6
+ secondaryBackgroundColor = "#F5F7FA"
7
+
8
+ [server]
9
+ port = 8501
10
+ headless = true
11
+ #--server.enableXsrfProtection false
12
+ #--server.enableCORS false
13
+ #--server.enableWebsocketCompression=false
14
+
15
+ [browser]
16
+ gatherUsageStats = false
17
+ #--browser.serverAddress 0.0.0.0
18
+ #--browser.serverPort 8080
19
+
20
+ [global]
21
+ developmentMode = false
22
+
23
+ #[general] # credentials.toml
24
+ #email = "313303303@qq.com
25
+
pages/1000_文本标识.py CHANGED
@@ -35,3 +35,5 @@ annotated_text(
35
  ("Community", "", "#8ef"),
36
  ("!", "", "#afa"),
37
  )
 
 
 
35
  ("Community", "", "#8ef"),
36
  ("!", "", "#afa"),
37
  )
38
+
39
+ "#8ef", "#faa"
pages/1003_streamlit_authenticator.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from meutils.pipe import *
2
+
3
+ import streamlit as st
4
+ import streamlit_authenticator as stauth
5
+ from streamlit_authenticator import Authenticate
6
+
7
+ from streamlit_option_menu import option_menu
8
+
9
+ # https://github.com/mkhorasani/Streamlit-Authenticator
10
+
11
+ st.set_page_config(page_title="Platform tester", page_icon=":rainbow:", layout="wide", initial_sidebar_state="auto")
12
+ # 如下代码数据,可以来自数据库
13
+ hashed_passwords = stauth.Hasher(['123', '456']).generate()
14
+
15
+ _ = f"""
16
+ credentials:
17
+ usernames:
18
+ nesc:
19
+ email: nesc@gmail.com
20
+ name: nesc
21
+ password: {hashed_passwords[0]} # To be replaced with hashed password
22
+
23
+ jsmith:
24
+ email: jsmith@gmail.com
25
+ name: John Smith
26
+ password: 123 # To be replaced with hashed password
27
+ rbriggs:
28
+ email: rbriggs@gmail.com
29
+ name: Rebecca Briggs
30
+ password: 456 # To be replaced with hashed password
31
+ cookie:
32
+ expiry_days: 30
33
+ key: some_signature_key
34
+ name: some_cookie_name
35
+ preauthorized:
36
+ emails:
37
+ - melsby@gmail.com
38
+ """
39
+
40
+ config = yaml.load(_)
41
+
42
+ authenticator = Authenticate(
43
+ config['credentials'],
44
+ config['cookie']['name'],
45
+ config['cookie']['key'],
46
+ config['cookie']['expiry_days'],
47
+ config['preauthorized']
48
+ )
49
+
50
+ name, authentication_status, username = authenticator.login('Login', 'main')
51
+ if authentication_status:
52
+ authenticator.logout('Logout', 'main')
53
+ st.write(f'Welcome *{name}*')
54
+ st.title('Some content')
55
+ elif authentication_status == False:
56
+ st.error('Username/password is incorrect')
57
+ elif authentication_status == None:
58
+ st.warning('Please enter your username and password')
59
+
60
+
61
+ if authentication_status:
62
+ try:
63
+ if authenticator.reset_password(username, 'Reset password'):
64
+ st.success('Password modified successfully')
65
+ except Exception as e:
66
+ st.error(e)
67
+
68
+
69
+ try:
70
+ if authenticator.register_user('Register user', preauthorization=False):
71
+ st.success('User registered successfully')
72
+ except Exception as e:
73
+ st.error(e)
74
+
75
+
76
+ try:
77
+ username_forgot_pw, email_forgot_password, random_password = authenticator.forgot_password('Forgot password')
78
+ if username_forgot_pw:
79
+ st.success('New password sent securely')
80
+ # Random password to be transferred to user securely
81
+ elif username_forgot_pw == False:
82
+ st.error('Username not found')
83
+ except Exception as e:
84
+ st.error(e)
pages/1004_streamlit_option_menu.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from meutils.pipe import *
2
+
3
+ import streamlit as st
4
+ from streamlit_option_menu import option_menu
5
+
6
+ st.set_page_config(page_title="Option Menu", layout="wide")
7
+ with st.sidebar:
8
+ selected = option_menu("Main Menu", ["Home", "Upload", "---", "Tasks", 'Settings'],
9
+ icons=['house', 'cloud-upload', None, "list-task", 'gear'], menu_icon="cast",
10
+ default_index=1)
11
+
12
+ selected2 = option_menu(None, ["Home", "Upload", "---", "Tasks", 'Settings'],
13
+ icons=['house', 'cloud-upload', None, "list-task", 'gear'],
14
+ menu_icon="cast", default_index=0, orientation="horizontal")
15
+
16
+ selected3 = option_menu(None, ["Home", "Upload", "Tasks", 'Settings'],
17
+ icons=['house', 'cloud-upload', "list-task", 'gear'],
18
+ menu_icon="cast", default_index=0, orientation="horizontal",
19
+ styles={
20
+ "container": {"padding": "0!important", "background-color": "#fafafa"},
21
+ "icon": {"color": "orange", "font-size": "25px"},
22
+ "nav-link": {"font-size": "25px", "text-align": "left", "margin": "0px",
23
+ "--hover-color": "#eee"},
24
+ "nav-link-selected": {"background-color": "green"},
25
+ }
26
+ )
27
+
28
+ # choice = option_menu(
29
+ # "Menu", ["首页", "HIVE", "KUDU", "MYSQL"],
30
+ # icons=['house', 'chat-square', 'chat-square-dots', 'chat-square-text'], menu_icon="hammer",
31
+ # default_index=0)
32
+
33
+ # df.style.set_precision
pages/3_🐧_分词.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from meutils.pipe import *
2
+
3
+ from appzoo.streamlit_app import Page
4
+
5
+ import streamlit as st
6
+
7
+ from LAC import LAC
8
+
9
+
10
+ # @st.experimental_memo(persist='disk', show_spinner=True, suppress_st_warning=False, max_entries=None, ttl=64)
11
+ @st.cache(func=None, persist=False, hash_funcs={'LAC.lac.LAC': str}, ttl=8)
12
+ def tokenizer1():
13
+ print('Loading tokenizer1...')
14
+ return LAC()
15
+
16
+
17
+ @st.experimental_singleton
18
+ def tokenizer2():
19
+ print('Loading tokenizer2...')
20
+ return LAC()
21
+
22
+
23
+ class MyPage(Page):
24
+
25
+ def main(self):
26
+ with st.form("Coding"):
27
+ text = st.text_input("输入文本", "")
28
+
29
+ if st.form_submit_button('开始转换'):
30
+ _ = tokenizer1().run(text)
31
+ _ = tokenizer2().run(text)
32
+
33
+ st.json(_)
34
+
35
+
36
+ if __name__ == '__main__':
37
+ app_title = "# 切词"
38
+ app_info = ""
39
+ MyPage(app_title=app_title, app_info=app_info).main()
pages/888_🌰_demo.py CHANGED
@@ -1,6 +1,8 @@
1
  from urllib.parse import urlencode, parse_qs
2
  import streamlit as st
3
 
 
 
4
  initial_query_params = st.session_state.get("initial_query_params")
5
  query_params = {k: v[0] for k, v in st.experimental_get_query_params().items()}
6
  if not initial_query_params:
@@ -24,3 +26,4 @@ with st.sidebar:
24
  '<div style="margin-top: 0.75em;"><a href="https://www.buymeacoffee.com/andfanilo" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a></div>',
25
  unsafe_allow_html=True,
26
  )
 
 
1
  from urllib.parse import urlencode, parse_qs
2
  import streamlit as st
3
 
4
+
5
+ st.json(st.session_state)
6
  initial_query_params = st.session_state.get("initial_query_params")
7
  query_params = {k: v[0] for k, v in st.experimental_get_query_params().items()}
8
  if not initial_query_params:
 
26
  '<div style="margin-top: 0.75em;"><a href="https://www.buymeacoffee.com/andfanilo" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a></div>',
27
  unsafe_allow_html=True,
28
  )
29
+ st.json(st.session_state)
requirements.txt CHANGED
@@ -3,6 +3,7 @@ appzoo
3
  pyecharts
4
  m2cgen
5
  psutil
 
6
 
7
  # streamlit
8
  streamlit==1.12.0
@@ -16,4 +17,6 @@ streamlit-agraph
16
  rdflib
17
  st-annotated-text
18
  streamlit-tree-select
19
- streamlit_pandas_profiling
 
 
 
3
  pyecharts
4
  m2cgen
5
  psutil
6
+ lac
7
 
8
  # streamlit
9
  streamlit==1.12.0
 
17
  rdflib
18
  st-annotated-text
19
  streamlit-tree-select
20
+ streamlit_pandas_profiling
21
+ streamlit_authenticator
22
+ streamlit_option_menu
run.sh CHANGED
@@ -6,7 +6,7 @@
6
  # @Software : PyCharm
7
  # @Description : ${DESCRIPTION}
8
 
9
- streamlit run _👋_.py
10
 
11
  #from streamlit import bootstrap
12
  #
 
6
  # @Software : PyCharm
7
  # @Description : ${DESCRIPTION}
8
 
9
+ streamlit run _👋_.py # --server.enableWebsocketCompression=false
10
 
11
  #from streamlit import bootstrap
12
  #