Python in a browser?

The future of web creation is here, whilst its marketing campain as a Javascript killer is a little ambitious at the moment Py-Script makes it possible to run Python in a web browser and having a little play with it has made me realise I needed this more than I thought. I have made a stupid simple python website that gives you 6 random numbers you could use on the lotto I call it “UK LOTTO NUMBER PICKER IN PYTHON” I know im a legend at naming projects. All jokes aside If you want to use it the link is: https://stephenwilde.net/lottogen/index.html


I will not be reviewing Py-Script as its unfair to do that at this stage as its in very early Alpha stages and its buggy and not to be used on production websites, we will ignore the fact I have used it on this website side bar 😉 Not to mention the fact it has 0 documentation yet!


the code I used to make this is below:

<html>
  <head>
    <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
    <script defer src="https://pyscript.net/alpha/pyscript.js"></script>
    <script>
    alert("This entire website was made with Python, CSS & HTML. The only Javascript is this box your reading now");
    </script>
  </head>
  <div html>
  <div>
<title>Lotto number picker | Python</title>
  <body>
   <center> 
   <div class="centered">
   <py-script> 
import random

numbers = [
    random.randrange(1, 59),
    random.randrange(1, 59),
    random.randrange(1, 59),
    random.randrange(1, 59),
    random.randrange(1, 59),
    random.randrange(1, 59)
]
numbers.sort()
print("UK Lotto number picker in Python")
print("I give you 6 random numbers from 1 to 59 every time you refresh its up to you what you play :)")
print(f'{numbers[0]} :: {numbers[1]} :: {numbers[2]} :: {numbers[3]} :: {numbers[4]} :: {numbers[5]}')
print ("If you win remember this websites owner, hahaha")
print(" - ")
print(" - ")
print(" - ")
print("A huge thank you to Py-Script for making this possible")
</py-script>
</div>
</body>
</html>

<style>
html {
  background-color: #6495ED; 
}


.centered {
  position: fixed;
  top: 50%;
  left: 50%;
  font-size: large;
  
  /* bring your own prefixes */
  transform: translate(-50%, -50%);
}


div {
  background-color: #00BFFF;
}
</style>

Honestly this is the most exciting thing to happen to web development in a long time and I have high hopes for the Py-Script project!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *