New library: stlite, a port of Streamlit to Wasm, powered by Pyodide

Thank you so much this works perfectly.

Just one point, in my case the <link> or loading from network using js does indeed work. the only case when it does not is if I try to access the network from inside the stlite script.

For example, this code works fine with Github pages, even though it requests the network:
<link type="text/css" rel="stylesheet" href="../src/styles.css">

In this case, is there any way to read the file that was loaded in the html header from stlite ? (for example in this case reading that styles.css file)

A bonus question:
Wouldn’t be nice to be able to use separately defined python files instead of including all the files in the html file ?
for example:

<link href="../code/main.py">
<link href="../code/tools.py">

then

stlite.mount(
  {...
    files: {
"code/main.py": loadFile("main.py"), 
},

this way it would be so much easier to maintain and edit the python code instead of doing so inside the html.

Very interesting.
I wonder, is it possible to do object tracking solution that could work on top of stlite?
Smooth video UX is not so important for this app, but I’d like to make nearly real time calculation of objects and object co-ordinates in the webcam video frame.

@pahotari Hi, thanks!
I’m not sure if a suitable object-tracking algorithm working on stlite/Pyodide is available,
but this real-time image processing demo app with scikit-image image filters may be the starting point:

In this app, in addition to stlite, the real-time video I/O relies on streamlit-fesion custom component, which is still in beta though.

@Abdelgha_4 thank you.

the only case when it does not is if I try to access the network from inside the stlite script .

That’s interesting, as I thought network access from an stlite script is the same as normal JS network access such as fetch() or XMLHttpRequest.
It makes sense if <link> works and JS doesn’t, as the network access with <link> may include some credentials to access secured resources. If it is this case, adding the same cookie to the request header from stlite scripts (pyfetch()) could be a solution.

is there any way to read the file that was loaded in the html header from stlite

I think it’s not possible.

A bonus question:

Makes sense, and the same approach using encodeB64ToArrayBuffer works for Python files for this purpose.
The discussion in the following issue may also help.

1 Like