The server can use a system call to determine number of network interfaces (wlan, ethernet). In the case there are multiple, it should provide both to the web-client, allowing the client to try an alternative connection should the first fail. This is particularly helpful for single-stream development when the pi hosts its own network on wifi but an Ethernet connection is present for upstream internet connection and development is done on this upstream machine.
This would require changing several versions of server.py and script.js in the examples.