[Twisted-web] How to use twistd on Windows to run a simple webserver
    Keith.Gunderson at act.org 
    Keith.Gunderson at act.org
       
    Tue Nov 22 12:52:17 MST 2005
    
    
  
I've finally found a good reason to delve into twisted at my job.  I've
been keeping up with your progress over the past few years, but now I can't
seem to get the simplest of webapps to run.  (I've read all the docs and
blogs that I can get my eyes on.)
The basics....No IRC during business hours,  Win2000, python2.4, latest
TwistedSumo plus TwistedWeb2 reinstalled for good measure.
I want to run the 'Simple application' described the twisted.web2
introduction.  (pasted below.)
Twistd.py has syslog issues for me.  My 'twistdWithSyslogRemoved.py' does
nothing but release an inaudible chirp.  (As does _twistd.py .)
What additional hints can you give me?  I have delusions of nevow,
mantissa, and glory in my future.  But one step at a time.
Many, many thanks.
(from intro.txt)
  from twisted.web2 import server, http, resource
  class Toplevel(resource.Resource):
    addSlash = True
    def render(self, ctx):
      return http.Response(stream="Hello monkey!")
  site = server.Site(Toplevel())
  # Standard twisted application Boilerplate
  from twisted.application import service, strports
  application = service.Application("demoserver")
  s = strports.service('tcp:8080', http.HTTPFactory(site))
  s.setServiceParent(application)
Save this program as ``example1.py``, and then run it via ``twistd -ny
example1.py``. ``twistd`` is the Twisted runner; it knows how to execute
applications by looking for the magic ``application`` variable declared at
top-level. You can also run your server daemonized, via ``twistd -oy
example1.py``. You can then access your server via the url
"http://localhost:8080/". For more deployment options, see the deployment_
chapter.
Keith Gunderson
Performance Test Analyst
IT Audit and Reporting
ACT, Inc.
301 ACT Drive
Iowa City, IA 52245
(319) 337-1548 Voice
(319) 337-1766 Fax
    
    
More information about the Twisted-web
mailing list