Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed Sep 13, 2022
1 parent 5a09c1b commit 967d7dc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,25 +181,31 @@ <h2>
<pre>
<code class="language-python" id="server">
import math
import sys

from twisted.internet import endpoints, protocol, task

from twisted.internet import protocol, endpoints, task

class Echo(protocol.Protocol):
def dataReceived(self, data):
self.transport.write(data)


class EchoFactory(protocol.Factory):
def buildProtocol(self, addr):
return Echo()


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>
Expand Down

0 comments on commit 967d7dc

Please sign in to comment.