Skip to content

Execute Javascript from Python Code

Maximilian Winter edited this page Nov 7, 2022 · 1 revision

It is very easy to execute javascript from python, you just have to define the javascript code you wanna execute on the website in a string and call "execute_javascript" with the string on the Pytonium instance:

# Get the current time and date to display it on our website.
now = datetime.now()
date_time = now.strftime("%d.%m.%Y, %H:%M:%S")
# Write javascript code to call a function and pass it the date and time.
code = f"window.state.setTicker('{date_time}')"
# Execute the javascript on the current site.
pytonium.execute_javascript(code)
Clone this wiki locally