chiark / gitweb /
fixes
[hippotat] / example.py
CommitLineData
b0eae083
IJ
1from twisted.internet import reactor, endpoints
2from twisted.web.server import Site
3from twisted.web.resource import Resource
4import time
5
6class ClockPage(Resource):
7 isLeaf = True
8 def render_GET(self, request):
9 request.setHeader("Content-Type", "text/plain; charset=utf-8")
10 return (
11 ("<html><body>%s</body></html>" % (time.ctime(),))
12 .encode('utf-8')
13 )
14
15resource = ClockPage()
16factory = Site(resource)
17endpoint = endpoints.TCP4ServerEndpoint(reactor, 8880)
18endpoint.listen(factory)
19reactor.run()