Getting browser country and time

Hi

I have an app that would be accessed globally. How can I access the country as well as the time from each person who uses the app? (Currently, the app would only provide these details based on where the app is hosted, right?)

Cheers

Hi @Shawn_Pereira,

Thanks for sharing this question! Is this app running locally or hosted on Community Cloud (or elsewhere)? You’re right that whether your app has access to this info depends on where the app is running/hosted

Thanks for responding, @Caroline. I forgot to mention that the app is being hosted on Streamlit cloud.

I wish to get the country and time info of each user via the code rather than other methods (developer access to analytics, etc…).

Is this possible with Streamlit?

Cheers

Hi @Shawn_Pereira,

Community Cloud doesn’t enable logging of IP addresses (mainly due to privacy implications), which would be the main way to get the viewer’s country (feel free to share your thoughts on this GitHub Issue if is a feature you feel strongly about).

You could record the time that the user is accessing the app by getting the current time and writing that value to a database. It looks like there are a few different ways to get the current time in Python, such as:

import datetime

current_time  = datetime.datetime.now()
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.