Changes between Version 249 and Version 250 of WikiStart


Ignore:
Timestamp:
08/05/2014 01:50:12 PM (4 years ago)
Author:
Glyph
Comment:

Use endpoints in the web server as well.

Legend:

Unmodified
Added
Removed
Modified
  • WikiStart

    v249 v250  
    145145#!python
    146146from twisted.web import server, resource
    147 from twisted.internet import reactor
    148 
    149 class HelloResource(resource.Resource):
     147from twisted.internet import reactor, endpoints
     148
     149class Counter(resource.Resource):
    150150    isLeaf = True
    151151    numberRequests = 0
    152    
     152
    153153    def render_GET(self, request):
    154154        self.numberRequests += 1
     
    156156        return "I am request #" + str(self.numberRequests) + "\n"
    157157
    158 reactor.listenTCP(8080, server.Site(HelloResource()))
     158endpoints.serverFromString(reactor, "tcp:8080").listen(server.Site(Counter()))
    159159reactor.run()
    160160}}}