How do I embed a python script into a web page?

Thread Starter

J4yd3n111

Joined May 6, 2019
1
So far, what i have is this from an online forum posted here over a year and a half ago:


  1. <script language="vbscript" type="text/vbscript">

  2. Function MyFunction()
  3. ' do some stuff
  4. End Function

  5. </script>
so what i figured was, instead of using vbscript, i needed to use python. I ended coming up with this, but i have no idea if it would be correct or what i would need more.


  1. <script language="python" type="text/python">

  2. import random
  3. code = random.choice(['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' ])
  4. print code
  5. </script>
is this at all correct? i know my python is correct as i have tested it before, but i am trying to see if that is the correct use of the code i found on this forum a year and a half ago. also, where would this code end up going in an html document? can it go anywhere where i want it on a webpage, like under a title if i want to link it to a button? or does it have to go in a certain place in an html document? ex.: <script language> code is following a <div> because it needs to be there or because it can go anywhere including after an <h1> command?
 

DraxDomax

Joined Apr 5, 2019
52
I wonder: where is the interpreter for this python? Is it executing inside an environment integrated in the browser or the user (website visitor) is expected to have a python runtime installed and active?
 
Top