Update app.py
Browse files
app.py
CHANGED
@@ -4,28 +4,27 @@ import streamlit as st
|
|
4 |
from streamlit import runtime
|
5 |
from streamlit.runtime.scriptrunner import get_script_run_ctx
|
6 |
|
7 |
-
|
8 |
-
#
|
9 |
|
10 |
-
#
|
11 |
-
#
|
12 |
-
#
|
13 |
-
#
|
14 |
|
15 |
-
#
|
16 |
-
#
|
17 |
-
#
|
18 |
-
#
|
19 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
# return session_info.request.remote_ip
|
22 |
-
def get_remote_ip():
|
23 |
-
try:
|
24 |
-
ip = requests.get('https://api64.ipify.org').text
|
25 |
-
return ip
|
26 |
-
except Exception as e:
|
27 |
-
st.error(f"Unable to get IP address: {e}")
|
28 |
-
return None
|
29 |
class ContextFilter(logging.Filter):
|
30 |
def filter(self, record):
|
31 |
record.user_ip = get_remote_ip()
|
|
|
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):
|
30 |
record.user_ip = get_remote_ip()
|