A port of Streamlit to Wasm, powered by Pyodide.
Visit the playground demo.
Here is a sample HTML page.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Stlite App</title>
</head>
<body>
<script src="https://whitphx.github.io/stlite/lib/application/stlite.js" ></script>
<script>
stlite.mount({
mainScriptData: `
import streamlit as st
name = st.text_input("Name")
st.write("Hello, ", name or "world")
`
})
</script>
</body>
</html>
In this sample,
- stlite library is imported with the first script tag, then the global
stlite
object becomes available. stlite.mount()
mounts Streamlit frontend on the<body />
element and runs the Python script passed through themainScriptData
option.
Warning stlite is at the very beginning of its development and the API can drastically change without any notice in the future. Moreover, the hosted JS runtime is not versioned now, so future API changes may cause problems with backward compatibility.
In the root directory,
make init
make
After building, you can run the playground app by running the command below. Access http://localhost:5001/
make serve