I used Brython https://brython.info. It works really well for simple scripts like this one. You can download the zip file and look at how it works.
You could try using this tool to port your game to the web https://github.com/gaudiatech/katasdk-public