OpenMarine

Full Version: Python in a web page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This looks quite interesting >>
https://www.anaconda.com/blog/pyscript-p...he-browser

Runs OK on a laptop - is there a webserver already installed in the openplotter image? Couldn't find apache so installed it, seems to work Smile

Code:
<html>
   <head>
     <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
     <script defer src="https://pyscript.net/alpha/pyscript.js"></script>
     <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
   </head>

 <body>
   <b><p>Today is <u><label id='today'></label></u></p></b>
   <br>
   <div id="pi" class="alert alert-primary"></div>
   <py-script>
import datetime as dt
pyscript.write('today', dt.date.today().strftime('%A %B %d, %Y'))

def wallis(n):
   pi = 2
   for i in range(1,n):
       pi *= 4 * i ** 2 / (4 * i ** 2 - 1)
   return pi

pi = wallis(100000)
pyscript.write('pi', f'π is approximately {pi:.3f}')
   </py-script>
 </body>
</html>


[Image: UnjbCQQ.png]
there is no webserver installed by default in OP.
I think that tool is something similar to Django: https://www.djangoproject.com/
Probably that will be the interface for OpenPlotter 4.