Is This the Easiest Way to Build Your Streamlit App?

Streamlit is an awesome way to build cool web apps with Python. Check out my blog post where I've talked about how you can use tools like Deepnote or Replit to code and test your Streamlit app, and deploy it on Streamlit Cloud.

But what if there was an easier way to do all this, without having to create accounts or logins?

Introduction

Yuichiro developed 'stlite', which is a port of Streamlit to WebAssembly (Wasm), powered by Pyodide. This project enables us to code and run Streamlit apps completely on web browsers! You can see this on the website 'Stlite Sharing', where we can code, run, and deploy our apps.

Instructions

Check out my step-by-step guide here on how to use Stlite Sharing. As an example, I made a simple app to compare the sector breakdown of the MSCI index ETFs of five Asian countries (data from Yahoo! Finance, as of 31st Dec 2022).

In the end, Stlite Sharing generates an URL that you can send to anybody who wants to view and interact with the app. All the details of the app are encoded in this URL, so all the recipient has to do is view it in a browser window.

Plus, your app lives on forever in this URL!

Challenges

The Stlite Sharing URL is too long! Isn't there a way to have a custom URL?

Answer: Since all the details of the app are encoded in the URL, it will be very long. Use a free link shortener like TinyUrl to get a shorter, custom URL. You can view my example app at: https://tinyurl.com/apac-sector-app.

I sent the URL to my colleagues. They are trying to view my Streamlit app but it is really slow to load!

Answer: Pyodide installs the environment and packages when the URL is launched, so it will take a while for the app to load completely.

Oh no! I shared the app URL with my colleagues, but I closed my Stlite Sharing window! What happens to my app now?!

Answer: Nothing will happen to your app. It will live on forever because the features of the app are encoded in the URL!

However, there are two things you need to remember:

  1. Once you have your app running and have shared the URL, make sure to save your code and data files locally or on GitHub. Stlite Sharing will not save your code once you close the window.

  2. Once you have closed the Stlite Sharing window, you cannot make any changes to this app. You can make a new app with the desired changes, but that will generate a new URL.

My Streamlit app uses some very particular Python packages, so it doesn't seem to work on Stlite Sharing!

Answer: Not all Python modules and packages will be available on Stlite Sharing, since it depends on what Pyodide can support. Check out Pyodide's documentation for details.

I made a lovely Streamlit app but the URL generated by Stlite Sharing is so long that it crashes any application that I copy&paste it into!

Answer: The more elaborate your Streamlit app, the more likely this is to happen. At the moment, Stlite Sharing works best for simple apps.

Conclusion

Try out Stlite Sharing for yourself! Also, don't forget to check out my example app at: https://tinyurl.com/apac-sector-app.