Solution 1 :

What you need is websocket.

WebSocket is a computer communications protocol, providing full-duplex communication channels over a single TCP connection. The WebSocket protocol was standardized by the IETF as RFC 6455 in 2011, and the WebSocket API in Web IDL is being standardized by the W3C

To start please read implementation of websocket in python.

Problem :

I have written a python script on bottle and hosted on pythonanywhere.
The python code basically just loads in different images into an HTML table and then users can type in commands to make things happen (consider it like chess where a new table is updated on every move).

I set up the html to refresh every time a command is sent, and every 20 seconds.

I would like for every user looking at the website to see the move last made immediately instead of having to refresh the page. Basically allowing them to play against each other in real time.

However I am not sure at all how to do this. The only idea I can think of is to force the webpage to refresh automatically every n second.

Perhaps I’m completely out of my depth, not even sure what to google. If someone could give me some links to figure out how to do this that would be great.


Comment posted by

That looks very promising, but sadly the pythonanywhere website appears to not support websockets. Source:

Comment posted by Glenn

In the absence of web sockets you could use javascript to poll for updates and then display them.

Comment posted by

@Rodrak if you wish there are a lot platforms to host python and test for free.