Skip to content

Instantly share code, notes, and snippets.

@codersofthedark
Last active December 15, 2015 16:49
Show Gist options
  • Save codersofthedark/5291824 to your computer and use it in GitHub Desktop.
Save codersofthedark/5291824 to your computer and use it in GitHub Desktop.
Twisted Example
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