Leave a comment

Using PyScript in a Streamlit page


Because why not ?
So what we have below is an HelloWorld that hosts an HelloWorld

import streamlit as st

from streamlit.components.v1 import html

st.write("Hello, is it me you looking for ?")

st.title("pyscript example")

html(
    """
    <script defer src='https://pyscript.net/latest/pyscript.js'></script>
    <py-script>
       from datetime import datetime
       now = datetime.now()
       display(now.strftime("%m/%d/%Y, %H:%M:%S"))
    </py-script>
    """)


The PyScript code is passed on to the browser that interprets it.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: