What you need is a socket server on the python end and a client/request server on the javascript end. For the python server side, refer to SocketServer , (example taken from there as well), one thing you have to make sure is to have the socket go past NAT (possibly port forwarding).
Read moreHow do I connect JavaScript to Python?
Create a POST API Endpoint
Read moreCan Python code be converted to JavaScript?
Did you know that it is possible to convert Python code to JavaScript? Well, yes! It is definitely possible . Although both are excellent programming languages with advantages and disadvantages, many beginning developers decide to start learning Python.
Read more