Hello! I've been developing a new part of my website and have managed to get it pretty much working in my debug environment. Tonight was the first go I've had at testing it live on PythonAnywhere. Needless to say, there were a lot of things I haven't got right yet! I can see my way through most of these, but the biggest problem seemed to be that I'd used websockets:
socketio.emit( "My channel", {"reload": True} )
in the back-end. Then, I intercept this in the front end with:
<script src="https://cdn.socket.io/4.7.5/socket.io.min.js"></script>
socket.on(...
To cut a long story short, this works fine in my development environment, but only works sporadically at best (possibly not at all) when hosted from PythonAnywhere. The upshot is that the new bit of the site is painfully slow. I disabled all the websockets code and it was much faster once I'd reloaded the website.
I did a search of the forum and found that websockets are not yet properly supported on PythonAnywhere. However, it is mentioned that 'outbound' websockets work. I don't know enough about any of this stuff to know whether my application qualifies as an 'outbound websocket' or not, so I have a few questions. Before I ask those, let me give a bit of background by explaining that the only reason I'm using these is that I might have multiple users looking at the same page and I want to trigger a browser update for all users if one of them makes a change. This might be the programming equivalent of using a sledgehammer to crack a nut. I don't really know what I'm doing, so this may well be the case.
Anyway, I'd really like answers to the following questions, and particularly any advice that anyone can offer:
- Is what I'm trying to do (with websockets) a complete non-starter on PythonAnywhere?
- If the answer to the first question is 'no', then any ideas what I might be doing wrong?
- If the answer to the first question is 'yes', what's the easiest way to achieve the same effect (firing browser refresh events from the server) without using websockets?
Any help is greatly appreciated! I'm practically a beginner with most of this stuff, so feel free to point out what might seem obvious.