Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
62 lines (43 sloc) 1.36 KB
#App level
from txweb import Site, expose
from twisted.web import server, resource
from twisted.internet import reactor
from twisted.web.static import File
from os.path import abspath, dirname, join
class PageOne(object):
def foo(self, request):
return "Hello From PageOne Foo!"
def delayed(self, request):
def delayedResponse():
request.write("I was delayed :( ")
reactor.callLater(5, delayedResponse)
return server.NOT_DONE_YET
class PageTwo(object):
def index(self, request):
""" /pagetwo/index """
return "Hello From PageTwo index!"
rootFile = lambda filename : abspath(join(dirname(__file__), filename))
class Root(object):
def index(self, request):
Will handle both / and /index paths
return "Hello From Index!"
def __default__(self, request):
Unless overriden further down, this will catch all 404's
return "I Caught %s " % request.path
pageone = PageOne()
pagetwo = PageTwo()
readme = File(rootFile(""))
license = File(rootFile("txweb/LICENSE.txt"))
reactor.listenTCP(80, Site(Root()) )