This is supposed to create a calender server on port 10310. Sadly the code runs and quickly exits with no errors. What could be the issue? According to the twisted O'reily book I am reading I should be able to go to localhost:10310/2013 and see a small calendar.
from twisted.internet import reactor
from twisted.web.resource import Resource, NoResource
from twisted.web.server import Site
from calendar import calendar
class YearPage(Resource):
def __init__(self, year):
Resource.__init__(self)
self.year = year
def render_GET(self, request):
return "<html><body><pre>%s</pre></body></html>" % (calendar(self.year),)
class CalendarHome(Resource):
def getChild(self, name, request):
if name == '':
return self
if name.isdigit():
return YearPage(int(name))
else:
return NoResource()
def render_GET(self, request):
return "<html><body>Welcome to the calendar server!</body></html>"
print("pop")
root = CalendarHome()
factory = Site(root)
reactor.listenTCP(10310, factory)
reactor.run
Thanks for any feedback.
reactor.run
should be reactor.run()
. See this page, for example.
reactor.run
is a function, while reactor.run()
calls the function.