How to Build & Share Streamlit Apps WITHOUT Installing Python
Introduction
Creating and sharing a Streamlit application has never been easier, especially if you can’t install Python on your work computer. PyCafe offers a solution that allows you to develop and share your Streamlit apps directly from your browser. In this post, I’ll walk you through the process of using PyCafe, highlighting its features and limitations.
PyCafe Interface
To get started, the first step is signing up for a free account on PyCafe. Once you have your account, you can create a new Streamlit project. The interface consists of three main sections:
- File Directory: Located on the left, you can create folders and files.
- Text Editor: In the center, this is where you’ll write your code.
- Real-time Application View: On the right, you see your Streamlit application running instantly.
PyCafe operates your application using WebAssembly, meaning it runs directly in your browser without needing a server. This allows for instant updates; simply save your code, refresh the page, and see the changes live.
Sharing a Project
Sharing your entire project is straightforward. Once you have your application ready, you can copy the project link and share it with others. They will see the same editor mode as you, allowing them to view and edit the code. However, their changes won’t be saved unless they publish the project themselves.
Sharing an App
If you want to share just the application, you can copy a slightly different link that includes “app” in the URL. This link will take users directly to the running app with a PyCafe banner at the top, allowing them to access the editor if needed.
Embedding in WordPress
Embedding your Streamlit app into a website is another fantastic feature. You can use an HTML iframe to include your app on platforms like WordPress. The iframe code can be pasted into an HTML block, and you can adjust the height to fit your design. Once embedded, the app functions seamlessly within your site.
Embedding in Notion
Embedding your Streamlit application in Notion is just as easy. Instead of an iframe, you can paste the app link directly into an embed block. This allows your application to be fully functional within your Notion workspace.
Embedding Streamlit Community Cloud Apps
It’s important to note that embedding isn’t exclusive to PyCafe. If you’ve deployed your app to the Streamlit Community Cloud, you can also embed those apps using an iframe or oEmbed. This feature enhances the versatility of sharing your applications.
PyCafe Limitations
While PyCafe is convenient, it does have some limitations. For instance:
- No support for threading.
- Inability to access the local file system.
- Not all Python packages are supported, although many popular ones are.
If a package is supported by Pyodide, it will work in PyCafe as well.
PyCafe Advantages
The advantages of using PyCafe are significant:
- No need for installation or infrastructure setup.
- Direct browser development means easy sharing with others.
- Scales to an infinite number of users without additional effort.
However, keep in mind that since your code runs in the browser, it can be viewed by users, so sensitive information should be avoided.
Additional Considerations
When working with PyCafe, it’s essential to avoid embedding sensitive information like API keys or database passwords in your code. You can allow users to input their own keys for services like OpenAI, but database credentials should be handled with care. Using a service like Superbase can help with security by allowing read-only access.
PyCafe Pricing
Currently, PyCafe offers free accounts that allow you to create and share public applications. There are plans for a pro version in the future that will enable private projects, but details are yet to be released.
Outro
In summary, PyCafe is a powerful tool for building and sharing Streamlit applications without the need for installation. It offers a user-friendly interface, quick sharing options, and the ability to embed applications in various platforms. If you’re interested in exploring this further, I encourage you to try it out and see how it fits your needs.