The main difference would be that you send you TCP shell commands (since it is some kind of Telnet) instead of sending an URL like it is currently in the example.
On your server, you would have some python scripts which will play role of TCP Server. Such example can be found at https://docs.python.org/2/library/socketserver.html , section "20.17.4.1. SocketServer.TCPServer Example"