diff --git a/index.html b/index.html index 74e8d38..f825ad5 100644 --- a/index.html +++ b/index.html @@ -180,18 +180,34 @@

                   
-from twisted.internet import protocol, reactor, endpoints
+import math
+import sys
+
+from twisted.internet import endpoints, protocol, task
+
 
 class Echo(protocol.Protocol):
     def dataReceived(self, data):
         self.transport.write(data)
 
+
 class EchoFactory(protocol.Factory):
     def buildProtocol(self, addr):
         return Echo()
 
-endpoints.serverFromString(reactor, "tcp:1234").listen(EchoFactory())
-reactor.run()
+
+async def echo_server(reactor):
+    await endpoints.serverFromString(reactor, "tcp:1234").listen(EchoFactory())
+    await task.deferLater(reactor, math.inf)
+    return 0
+
+
+def main():
+    return task.react(echo_server)
+
+
+if __name__ == "__main__":
+    sys.exit(main())