Skip to content

Instantly share code, notes, and snippets.

@clemesha-ooi
Created March 19, 2010 23:02
Show Gist options
  • Save clemesha-ooi/338294 to your computer and use it in GitHub Desktop.
Save clemesha-ooi/338294 to your computer and use it in GitHub Desktop.
from twisted.web.server import Site
from twisted.web.resource import Resource
from twisted.internet import reactor
class Home(Resource):
def render(self, request):
return "homepage"
class Data(Resource):
def render(self, request):
return "data"
class Station(Resource):
def getChild(self, path, request):
print "Station - path, request", path, request
return self
def render(self, request):
print "request.uri", request.uri
args = request.uri.split("/")[2:]
return "station - args => %s " % str(args)
root = Resource()
root.putChild("", Home())
root.putChild("data", Data())
root.putChild("station", Station())
factory = Site(root)
reactor.listenTCP(8880, factory)
reactor.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment