I’ve got a simple streamlit app that accepts get parameters in the browser bar, but it will not report parameters from a command line call, for example using curl.
curl reports a successful interaction but nothing shows up in the streamlit app.
how can I make get request parameters show up in streamlit from the command line?
screenshot with successful get parameters received from browser:
Query parameters are tied to a particular session, so if you access the app from your command line it won’t have any impact on another session you are viewing in a browser tab. Streamlit runs on a Tornado server (HTTP + WebSocket). Each connection is a distinct session. If you are viewing the app from two different browser tabs, they don’t know anything about each others’ query parameters.
To step back a level, what are you trying accomplish with these messages?
I’m trying to bring in about 8 to 12 numbers from a weather station, live, straight from the sensors.
so if I can figure out how to get the data from behind my university firewall into the streamlit community cloud app, it’ll need to be delivered in a way that is persistent across multiple sessions.
there are a few examples on persistent session states, but that’s not my current problem.
the first issue is access to streaming data, live, with updates around every second. it’s a straightforward http get or even a udp message, but these are disallowed.
the streaming case seems to be something that streamlit has avoided
It is not clear to me how the API of the weather stations works. I’m picturing a recurring st.fragment (i.e. with the run_every argument) that makes a request of the data. Is that kind of HTTP request not possible?
By streaming, you mean the weather station writing to some database (external to Streamlit Cloud), which then is queried by the webapp?
well, the raspberry pi is behind a firewall. it has outbound access but no inbound access. establishing a two-way communication channel, like a websocket, would be ideal because it provides a tcp connection over standard http ports. I’ve never used websockets before and am exploring them. if a websocket can be initiated by the pi, then either side could determine the data transfer interval.
there is no storage strictly necessary to display current sensor data, but a small history of 10 or 50 points wouldn’t be too difficult using session state.
the st.fragment method could be helpful. I’d rather have a periodic callback (a callback timer) rather than a button.
the pi has the data directly from the sensors, so delivering the latest array of floating point numbers is as straightforward as websocket.send()'ing them in the websocket connection with a framing terminator so the streamlit side knows when the message is complete.
the pi API can be made however. sending directly from sensors to the streamlit app is the goal. I don’t see any need for an intermediate database. that would add an extra unecesssry step.
I’ve got the command line sender and streamlit receiver working working with flask but the community cloud doesn’t support flask.
the challenge is to go establish an open connection between the two computers with firewall restrictions
That’s why I thought of the raspberry pi writing to an external database from which the web app reads every so often. Presumably, you will want the historical data of the sensors as well. I understand why you’d want a direct communication between sensors and app, but I suspect writing to/reading from a database every 5s or so will not add a considerable overhead.
Every user have their own session state, but the current data should be the same for all users. You perhaps want to update a cached resource (st.cache_resource - Streamlit Docs), setting the ttl argument to some time step the app would refresh with new data.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.