Last active
December 15, 2015 16:49
-
-
Save codersofthedark/5291824 to your computer and use it in GitHub Desktop.
Twisted Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.web import server, resource | |
from twisted.internet import reactor | |
class HelloResource(resource.Resource): | |
isLeaf = True | |
numberRequests = 0 | |
def render_GET(self, request): | |
self.numberRequests += 1 | |
request.setHeader("content-type", "text/plain") | |
return "I am request #" + str(self.numberRequests) + "\n" | |
reactor.listenTCP(8080, server.Site(HelloResource())) | |
reactor.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment