Changes between Version 261 and Version 262 of WikiStart


Ignore:
Timestamp:
02/09/2016 02:15:27 AM (3 years ago)
Author:
Tristan Seligmann
Comment:

Make web and pubsub examples Python 3 compatible

Legend:

Unmodified
Added
Removed
Modified
  • WikiStart

    v261 v262  
    156156    def render_GET(self, request):
    157157        self.numberRequests += 1
    158         request.setHeader("content-type", "text/plain")
    159         return "I am request #" + str(self.numberRequests) + "\n"
     158        request.setHeader(b"content-type", b"text/plain")
     159        content = u"I am request #{}\n".format(self.numberRequests)
     160        return content.encode("ascii")
    160161
    161162endpoints.serverFromString(reactor, "tcp:8080").listen(server.Site(Counter()))
     
    187188    def lineReceived(self, line):
    188189        for c in self.factory.clients:
    189             c.sendLine("<{}> {}".format(self.transport.getHost(), line))
     190            source = u"<{}> ".format(self.transport.getHost()).encode("ascii")
     191            c.sendLine(source + line)
    190192
    191193class PubFactory(protocol.Factory):