KiteWind / templates /stlite /stlite-snippet-template.html
gstaff's picture
Cleanup and move template to utility file.
4b286f3
raw
history blame
1.38 kB
<div id="KiteWindApp">
<iframe id="demo-iframe" width="100%" height="512px" src="about:blank"></iframe>
<script>
const template = \`<div id="root"></div>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@stlite/[email protected]/build/stlite.css"/>
<script src="https://cdn.jsdelivr.net/npm/@stlite/[email protected]/build/stlite.js"><\\\/script>
<script>
const streamlitConfig = "[server]\\\\nrunOnSave = true";
const code = \\\`STARTING_CODE\\\`;
const appController = stlite.mount({
requirements: ["matplotlib"], // Packages to install
entrypoint: "streamlit_app.py", // The target file of the streamlit run command
files: {
".streamlit/config.toml": streamlitConfig,
"streamlit_app.py": code,
},
}, document.getElementById("root"));
// Returned controller functions defined here:
window.appController = appController;
<\\\/script>\`
const frame = document.getElementById('demo-iframe');
frame.contentWindow.document.open();
frame.contentWindow.document.write(template);
frame.contentWindow.document.close();
</script>
</div>