Skip to content

TypeError: Expected user agent to be a string, got 0 #21

Description

@csipapicsa

File "/usr/_streamlit_playground/nginx_test_page.py", line 26, in nginx_test_page_init
user_agent = parse(ua_string)
File "/usr/_streamlit_playground/streamlit_dev_env/lib64/python3.9/site-packages/user_agents/parsers.py", line 268, in parse
return UserAgent(user_agent_string)
File "/usr/_streamlit_playground/streamlit_dev_env/lib64/python3.9/site-packages/user_agents/parsers.py", line 136, in init
ua_dict = user_agent_parser.Parse(user_agent_string)
File "/usr/_streamlit_playground/streamlit_dev_env/lib64/python3.9/site-packages/ua_parser/user_agent_parser.py", line 227, in Parse
entry = _lookup(user_agent_string)
File "/usr/_streamlit_playground/streamlit_dev_env/lib64/python3.9/site-packages/ua_parser/user_agent_parser.py", line 192, in _lookup
raise TypeError(f"Expected user agent to be a string, got {ua!r}")

Code:

from streamlit_javascript import st_javascript
from user_agents import parse

ua_string = st_javascript("""window.navigator.userAgent;""")
user_agent = parse(ua_string)
st.write(ua_string)
st.session_state.is_session_pc = user_agent.is_pc
st.info(st.session_state.is_session_pc)     

Version: There is no version info

Probably a strict nginx configuration is causing it, but still, it should not be an issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions