[Twisted-Python] IP address, server

Erik van Blokland erik at letterror.com
Fri Jun 20 09:26:20 EDT 2003


a humble question for a nudge in the right direction. I'm
utterly new to twisted, but I have a lot of experience in
python. I'm trying to get a tiny working demo to play with
and learn. I've installed twisted 1.0.5 on a Mac G3 running
10.2.6 OSX. Python 2.3b1. runtests seems to work.

The tiny http server script works when I take a browser on
the same machine as the server and look at, I get the expected result, so the
server is alive. When I take a look from a different machine
using the local IP address of the server
I get no response. Other services over my network to the
server work fine. Do I need to do more, listen to a specific
port, tell the server the IP address? Is this supposed to
work and the problem lies elsewhere, OS perhaps (would be
good to know too)

This is my test script:

from twisted.web import resource
from twisted.web import server
from twisted.internet import reactor


class MyServer(resource.Resource):
    isLeaf = True
    def render(self, httprequest):
        hdr = httprequest.getAllHeaders()
        html = '<html><body>Have a nice day

        httprequest.setHeader('Content-Length', len(html))
        httprequest.setHeader('Content-Type', 'html/plain')

aserver = MyServer()
site = server.Site(aserver)
reactor.listenTCP(HTTP_PORT, site)

Any pointers would be appreciated. Sorry if this is a dumb

Erik van Blokland

More information about the Twisted-Python mailing list