Streamlit dashboards

The recent events with the colonial pipeline drew a lot of attention to gas stations and gas prices everywhere, and in the back of my head I had been wanting to try out streamlit’s free hosting capabilities and the plotting library altair.

Streamlit is a data dashboard tool. Altair is a data visualization tool. I found a twitter post about gasbuddy hosting a query-able API, like this endpoint. This was already enough to build out a dashboard to query gasbuddy for gas prices and share them in an (interactive) altair plot on streamlit. In this implemention, I’m using python’s threading library to launch separate threads to query gas buddy.

To beef things up more, I’m using a personal S3 bucket to store and recall any pulled data. Streamlit also provides a nice secrets utility to safely store sensitive information like AWS credentials or the IDs of gas stations near me.

I think there’s still room for improvement, like the gas price querying on streamlit only occurs when someone visits the URL and launches the dashboard (which then launches parallel threads to query gas buddy). If no one is active on the streamlit app, then there will be no scraping threads. It might be better to use some sort of local server/bot to periodically query gasbuddy and not rely on streamlit to do the scraping.

In summary, I recommend people give streamlit a shot at deploying a (free) application!