This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python in a web page
#1
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]
Reply
#2
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)