streamlit-extras icon indicating copy to clipboard operation
streamlit-extras copied to clipboard

Add https://github.com/arnaudmiribel/streamlit-to-stlite

Open arnaudmiribel opened this issue 2 years ago • 3 comments

Whenever you feel like it @blackary!

arnaudmiribel avatar Oct 05 '22 20:10 arnaudmiribel

Think we're in a good-enough state for this one @blackary? Pretty sweet one tbh. Would probably only scope the .html downloader button presumably

arnaudmiribel avatar Nov 17 '22 23:11 arnaudmiribel

Tangentially related, but @LukasMasuch came up with a fun way to embed... stlite within Streamlit. It is useful if you want to have a safe python kernel to eval from (since this runs on the client side, no security risk).

from streamlit.components.v1 import html

html(
    """
        <!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>
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/@stlite/[email protected]/build/stlite.css"
    />
  </head>
  <body>
    <div id="root"></div>
    <script src="https://cdn.jsdelivr.net/npm/@stlite/[email protected]/build/stlite.js"></script>
    <script>
      if (window.location.search !== "?embed=true") {
        window.location.search = "?embed=true";
      }
      stlite.mount(
        `
import streamlit as st

st.markdown('<style>[data-baseweb~="modal"]{visibility: hidden;}</style>', unsafe_allow_html=True,)

name = st.text_input('Your name')
st.write("Hello,", name or "world")
`,
        document.getElementById("root")
      );
    </script>
  </body>
</html>
        """
)

arnaudmiribel avatar Feb 01 '23 14:02 arnaudmiribel

btw. I have a demo app here [Code].

lukasmasuch avatar Feb 01 '23 14:02 lukasmasuch