Why Twisted resource.Resource execute render() twice?
Question: Im new to Twisted. Why is it printing "render()" twice? I know if I return
server.NOT_DONE_YET, it will only print once, but I wish to return string/JSON
instead. Any help?

Code:

    
    
    from twisted.web import resource, server
    from twisted.internet import reactor
    import simplejson
    
    class WResource(resource.Resource):
        isLeaf=True
    
        def __init__(self):
            print "resource started"
    
        def render(self, request):
            print "render()"
            request.setHeader('Content-Type', 'application/json')
            return simplejson.dumps(dict(through_port=8080, subdomain='hello'))
    
    reactor.listenTCP(9000, server.Site(WResource()))
    reactor.run()
    

Output:

    
    
    > python server.py
    resource started
    render()
    render()
    


Answer: Because your web browser is requesting `favicon.ico`. If you print
`request.postpath` in your `render` method, you'll see that only one of the
requests is hitting the page that you expect.

