In Defense of Taps (was Re: [Twisted-Python] where to begin)

William Dode wilk-ml at flibuste.net
Tue Feb 11 05:07:37 MST 2003


Moshe Zadka <twisted at moshez.org> writes:

> On 11 Feb 2003, William Dode <wilk-ml at flibuste.net> wrote:
> 
> > So, is there an example of a web server without using tap and twistd
> > command line ?
> 
> '''
> from twisted.web import server, static
> from twisted.internet import reactor
> 
> root = static.Data("hello world", "text/plain")
> root.putChild('', root)
> # root.putChild('name-of-my-script', myScriptResource)
> site = server.Site(root)
> reactor.listenTCP(10998, root)
> reactor.run()
> '''

thanks, it's a good starting point for me. I can begin to work !

just that it did'nt work like that :

Traceback (most recent call last):
  File "<stdin>", line 8, in ?
  File "/usr/lib/python2.1/site-packages/twisted/internet/default.py", line 232, in listenTCP
    p.startListening()
  File "/usr/lib/python2.1/site-packages/twisted/internet/tcp.py", line 398, in startListening
    self.factory.doStart()
AttributeError: Data instance has no attribute 'doStart'

but i did (is it a good way ?) :

import twisted.web.resource
class MyGreatResource(twisted.web.resource.Resource):
    def render(self, request):
        request.write(request.uri)
	request.write("<br>")
        request.write("%s<form method=post><input type=text name=vvv><input type=submit></form>"%(str(request.args)))
    	return ""

    def isLeaf(self):
        return true

resource = MyGreatResource()

from twisted.internet import app
from twisted.web import static, server, vhost, twcgi, script, trp

site = server.Site(resource)
application = app.Application('web')
application.listenTCP(10999, site)
application.run()

> 
> > I would like to make a web server that could be embed in an .exe with
> > py2exe.
> 
> No, you wouldn't.

why ?

-- 
William Dode - http://flibuste.net




More information about the Twisted-Python mailing list