How to create beautiful apps in just minutes

Jonathan Loscalzo
Hexacta Engineering
2 min readJul 21, 2021

Do you need to show a model, present information, or communicate some insights in an agile way? In this post, I’m going to let you know how Streamlit helped me to tell a story with data, go ahead and discover it!

Screenshot from our running script
Screenshot from our script running

Intro

We have been working on developing a complete software application with backend, frontend, docker, and many other components… But, we need to build a piece of code that gives us the ability to simplyfy testing and find out some configuration parameters which help the core software.
In the scenario described, we need to involve many actors such developers, designers, testers, in order to define and build a complete new feature, even if we don’t know whether is the correct approach

In that case, we would rather have a cheaply-speedy solution to evaluate our insights than work with many people on the core solution.

Besides that, we need to adjust the parameters and present outcomes with visualizations. Once we have played with it and found the correct ones, we will end up setting it in our application.

We use Streamlit, which allows rapid prototyping of a web app solution with just one software language, giving us the ability to simplify developing and finding out which are the best configuration parameters for our application.

According to the official page: “Streamlit turns data scripts into shareable web apps in minutes. All in Python. All for free. No front‑end experience required.”

Show me the code

Installing streamlit is easy, in your virtual environment:

pip install streamlit

Streamlit lets us working whatever file structure we want, we could decide to simply develop an entirely script or in a more modular way.

So, I built one entire script, saved it on gists, and now I can run it with just one command:

streamlit run https://gist.githubusercontent.com/JonathanLoscalzo/6bb2de18c867f13fa02248771a65fce7/raw/0b100dcce940078d4d680c94f477d814aa810d7b/sklearn_tuto.py

Remember that if you don’t have deps from the script, in this case sklearn, matplotlib, pandas, numpy and streamlit, it won’t run.
Just same case if your script has file-deps like images or data.

The whole script:

Now, we could evaluate hyperparameters visually, not so performant to find best set of them, but very enjoyable.

For deploying, Streamlit offers a “sharing-feature”, but you have to ask for an invite. Also, at its forum, community is sharing their strategies, so go ahead there: https://discuss.streamlit.io/t/streamlit-deployment-guide-wiki/5099.

To Illustrate this, we could run it with a Colab Notebook and Ngrok:

In our case, we have to visualize outcomes of an akward formula, and we will add more features to feed this calculation, you could use any python libs, such request or SQLAlchemy to get the data.

Thanks to get here, if you have any suggestion, or comments, please share it!

--

--

Jonathan Loscalzo
Hexacta Engineering

Proactive, Developer & Student. Interested in Software Craftsmanship & DataScience