robertselvam commited on
Commit
d8ce952
·
verified ·
1 Parent(s): 80b39dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -14
app.py CHANGED
@@ -4,26 +4,34 @@ import streamlit as st
4
  from streamlit import runtime
5
  from streamlit.runtime.scriptrunner import get_script_run_ctx
6
 
7
- def get_remote_ip() -> str:
8
- # """Get remote ip."""
9
 
10
- # try:
11
- # ctx = get_script_run_ctx()
12
- # if ctx is None:
13
- # return None
14
 
15
- # session_info = runtime.get_instance().get_client(ctx.session_id)
16
- # if session_info is None:
17
- # return None
18
- # except Exception as e:
19
- # return None
20
 
21
- return getpass.getuser()
22
 
23
- import streamlit as st
24
  import getpass
25
 
26
- st.write(getpass.getuser())
 
 
 
 
 
 
 
 
 
27
 
28
  class ContextFilter(logging.Filter):
29
  def filter(self, record):
 
4
  from streamlit import runtime
5
  from streamlit.runtime.scriptrunner import get_script_run_ctx
6
 
7
+ # def get_remote_ip() -> str:
8
+ # # """Get remote ip."""
9
 
10
+ # # try:
11
+ # # ctx = get_script_run_ctx()
12
+ # # if ctx is None:
13
+ # # return None
14
 
15
+ # # session_info = runtime.get_instance().get_client(ctx.session_id)
16
+ # # if session_info is None:
17
+ # # return None
18
+ # # except Exception as e:
19
+ # # return None
20
 
21
+ # return getpass.getuser()
22
 
 
23
  import getpass
24
 
25
+ def get_remote_ip():
26
+ try:
27
+ username = getpass.getuser()
28
+ return username
29
+ except Exception as e:
30
+ return str(e)
31
+
32
+ # Example usage
33
+ st.write(get_current_username())
34
+
35
 
36
  class ContextFilter(logging.Filter):
37
  def filter(self, record):