Integrated Streamlit preview on VSCode with Wasm/Pyodide-powered "stlite"

Hi community,

I have developed Wasm/Pyodide-ported serverless Streamlit, “stlite” (forum post), and just released a VSCode extension to use in in your VSCode workspace.

Install and try it! :point_down:

You can launch a preview panel from the “Launch stlite preview” command in the command palette.
CleanShot 2023-03-25 at 16.31.46

One interesting usage is VSCode for the Web or GitHub Codespaces.
Since this extension executes Python (Pyodide) and Streamlit on your browser, by installing it on your Codespaces, you can edit and run the Streamlit app without any server setup.

A sample Codespace is https://github.dev/whitphx/streamlit-sample

Notes:

  • As “stlite” is kind of a customized version of Streamlit, it has some differences and restrictions. See GitHub - whitphx/stlite: Serverless Streamlit
  • The current version of the extension uses @stlite/mountable in the same way as this section in the README, which means the stlite resources are downloaded from the CDN every time you launch the extension, so it can’t start offline.
9 Likes

Is there a documentation on how to run it would be ideal.

1 Like

Thanks! I updated it :smiley:

1 Like

So cool!!!

1 Like

I’m just a novice and I think that Streamlit and stlite sounds very interesting coding platforms.
I tried to configure coding environment with Visual code and now I have problem with stlite preview window.
I have installed slite extension v0.3.10 to VC, and then I followed those extension instructions three steps: 1. launch stlite preview…

But some reason I can’t select file. File list just flash and then it disappears, and no preview window exists.

Any ideas what to do?

I have next configuration:
Windows 10
WSL2, Ubuntu 22.04.2
Visual code desktop, Version: 1.77.3 (user setup)
Python 3.10.6
I tried very basic project app.py file which has:

import streamlit as st
st.write(“# Header 1”)

Smartlite run app.py works very well.

@pahotari Thank you for giving it a trial!
It might be a Windows-specific problem, although I haven’t confirmed it yet because currently I’m traveling and don’t have an access to Windows env.
Sorry but please be patient until the fix.

Hello, the extension cannot be installed because system warns the version doesn’t match with vscode

VS Code version is 1.63.2

Have you tried updating VSCode? 1.63.2 is from November 2021 so it predates this extension.

I tried this again. When I tried to select the file(app.py) many times, sometimes the file selection was successful. But when it sometimes start preview window, I got the following error message in the preview window:
FileNotFoundError: [Errno 44] No such file or directory: ‘/home/\home\myname\projects\stdetection\x07pp.py’