Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,34 @@ <h2>
</p>
<pre>
<code class="language-python" id="server">
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())
</code>
</pre>
<p>
Expand Down